Bonjour à tous,
J'ai fait un script qui permet de faire un genre de backup selon le dossier source et le disque de destination que sélectionne l'utilisateur :
display dialog "Backup Application, Before continue make sure you have plugged an external support to do the backup" default button "OK"
display dialog "To backup one, or some files press 1
To backup an entire folder press 2
To Backup multiples folders press 3 :" default answer ""
set typeOfBackup to the text returned of the result
tell application "Finder"
--Sauvegarde de fichiers
if typeOfBackup = "1" then
set source to choose file default location (path to documents folder) with multiple selections allowed
get name of every disk whose ejectable is true
try
set externalLocation to ((choose from list result with prompt "Select your external Disk from the list : ") as text)
end try
duplicate source to externalLocation
else if typeOfBackup = "2" then
set sourceFolder to choose folder with prompt "Select a folder" default location (path to documents folder)
get name of every disk whose ejectable is true
try
set externalLocation to ((choose from list result with prompt "Select your external Disk from the list : ") as text)
end try
duplicate sourceFolder to externalLocation
else if typeOfBackup = "3" then
set sourcesFolder to choose folder with prompt "Select folders" default location (path to documents folder) with multiple selections allowed
get name of every disk whose ejectable is true
try
set externalLocation to ((choose from list result with prompt "Select your external Disk from the list : ") as text)
end try
duplicate sourcesFolder to externalLocation
end if
end tell
Le problème est quand je veux rajouter une condition. Par exemple , après cette ligne :
try
set externalLocation to ((choose from list result with prompt "Select your external Disk from the list : ") as text)
end try
si je rajoute un if pour dire que le fichier à copier existe déjà et que je compile :
if typeOfBackup = "1" then
set source to choose file default location (path to documents folder) with multiple selections allowed
get name of every disk whose ejectable is true
try
set externalLocation to ((choose from list result with prompt "Select your external Disk from the list : ") as text)
end try
if (exists file source of externalLocation) then
display dialog "ATTENTION ! Fichier dèja présent sur le support externe, le remplacer ?"
set resp to the text returned of the result
if resp = "oui" then
duplicate source to externalLocation
end if
end if
J'obtiens l'erreur suivante : Il est impossible de rendre alias "MacintoshHD:Users:username:Documents:test.txt" en type integer.
Quelqu'un aurait-il la solution à ce problème ?
Merci :-)
Partager