Q: Change Filename of Selection to "Import.xls" in Applescript
Hi, I'm way back in Tiger, but I am trying to change the name of a file in a folder (which may be whatever name it is) to a known name. Ultimately, I'm just trying to import a known file to filemaker and need the name to be a known name. This is what i Have thus far, but I'm just not having success. This goes to the folder window 2 and selects the first file...no problem, but from there I can't seem to get it to change the name to "import.xls". Only excel files will be present in this folder, so I'm not worried about that.
The other thing I would like to accomplish is if there is no file in that folder than skip over everything and do nothing.
Thanks for your help!!!
tell application "Finder"
activate
set target of Finder window 2 to folder "Orders_to_Enter" of folder "Documents" of folder "MINIJOHN"of folder "Users" of startup disk
select first file of Finder window 2
try
set the name of the selection to "IMPORT.xls"
end try
end tell
tell
Mac mini, Mac OS X (10.6.8), Applescript
Posted on Oct 4, 2016 11:51 PM
Hello
No need to manipulate selection. You may simply write something like this:
set d to (path to documents folder as string) & "Orders_to_Enter:" as alias tell application "Finder" --open item d -- optional tell (item d's file 1 whose name extension = "xls") try set name to "IMPORT.xls" end try end tell end tell
Tested under OS X 10.6.8.
Good luck,
H
Posted on Oct 5, 2016 1:41 AM