Really simple, how do I rename a folder?
You have to use the Finder:
set a to choose folder
tell application "Finder" to set a's name to (text returned of (display dialog "New folder name:" default answer ""))
Good luck,
Almost…
What if I alread know the path and know what I want the name to be?
Is this more what you mean?
set a to "Macintosh HD:Users:dadprogram:Desktop:Junk:"
tell application "Finder" to set folder a's name to "Mess"
I get an error saying, "Can’t set the name of “Promethius:Backup:” to “Backup_old”.
Here is the code. I have the variables split up because of code not included.
set bckpdisk to "Promethius"
set bckpdest to bckpdisk & ":Backup"
if (folder bckpdest exists) then
set (bckpdest & ":")'s name to "Backup_old"
end if
You are getting closer. Whenever you need to communicate with or about folders, you need to use the Finder:
set bckpdisk to "Promethius"
set bckpdest to bckpdisk & ":Backup"
tell application "Finder"
if (folder bckpdest exists) then
set (folder bckpdest)'s name to "Backup_old"
else
display dialog "Not there, Mister."
end if
end tell
Try that out, and see if it works.
Well, I had this all operating under a tell application “Finder” … end tell. The problem was that I needed to tell it to change folder name not just put the path.
Thanks again for your help.