Hi, I’ve been trying this for a few hours now with little to no success. What I want the script to do is create a folder inside the backup folder of the disk “THE BACK FORTY” (my father’s firewire 40 gig), and name the file with the current date. I’ve browsed the forum looking for examples and got andy_boretto’s example copied over to my own script. It looks as follows:
tell application "Finder"
set file_location to "THE BACK FORTY:Backup:" as string
set folder_name to do shell script "date +%m/%d/%y" as string
set file_path to ((file_location as string) & folder_name & ":") as string
make new folder at file_location with properties {name:"TEMP"}
set file_alias to ("THE BACK FORTY:Backup:TEMP") as alias
set name of file_alias to file_path
end tell
Whenever I try to run it, I get an error saying “The Finder got an error: the operation could not be completed.”
Can someone please explain to me what’s going wrong, because it’re pretty obvious that neither the Finder nor the Script Editor are so forthcoming.
P.S.: How would I have the script check for and delete any existing TEMP folder (from say, an aborted script execution) before the rest of the operation begins?
One thing that is likely to cause problems is where the script is trying to set the name of something to “THE BACK FORTY:Backup:08/23/03:”.
set name of file_alias to file_path
That won’t be allowed because colons are used in file and folder paths. Does this do what you want?
set file_location to "THE BACK FORTY:Backup:"
set folder_name to do shell script "date +%m/%d/%y"
set file_path to ((file_location as string) & folder_name & ":")
set file_alias to ("THE BACK FORTY:Backup:TEMP") as alias
tell application "Finder"
make new folder at folder file_location with properties {name:"TEMP"}
set name of file_alias to folder_name
end tell
Well, as originally entered, it didn’t work, but I shifted it around like so:
tell application "Finder"
make new folder at folder "THE BACK FORTY:Backup:" with properties {name:"TEMP"}
end tell
set file_location to "THE BACK FORTY:Backup:"
set folder_name to do shell script "date +%m/%d/%y"
set file_path to ((file_location as string) & folder_name & ":")
set file_alias to ("THE BACK FORTY:Backup:TEMP") as alias
tell application "Finder"
set name of file_alias to folder_name
end tell