Okay, i do not know scripting at all but i have done some searching and came up with this… i am far from what i am wanting to do… any help would be great!
I have an excel file that is generated with Original file names and the new names we want to rename to… i am able to read the excel file and get the old and new names out of there. HOWEVER i cannot figure out how to rename the actual files. i keep getting errors.
Now all that said, here is the twist, I will have MULTIPLE rows of old and new filenames in the excel sheet. i need the script to loop so that it will name to old filename with the new filename for all the files (rows) in the sheet/actual file folder!
I really hope this makes sense… let me know if you need more info!!! thanks for any help i get!!!
set excelFile to choose file with prompt "Choose the Excel file" of type {"XLS6", "XLS7", "XLS8"}
set theFolder to choose folder with prompt "Choose the folder containing the files to rename"
tell application "Microsoft Excel"
open excelFile
set myVarOld to get value of cell "F2"
set myVarNewto get value of cell "I2"
end tell
tell application "Finder"
set the name of file myVarOld to myVarNew of folder theFolder
end tell
AppleScript: 2.3
Browser: Firefox 5.0
Operating System: Mac OS X (10.6)
This could work…
set excelFile to choose file with prompt "Choose the Excel file" of type {"XLS6", "XLS7", "XLS8", "XLSX"}
set theFolder to choose folder with prompt "Choose the folder containing the files to rename"
--get a list of the old and the new filenames
set oldnames to {}
set newnames to {}
tell application "Microsoft Excel"
open excelFile
tell document 1
tell sheet 1
repeat with i from 1 to 9999
if value of cell ("F" & i as text) ≠"" then
set oldnames to oldnames & value of cell ("F" & i as text)
set newnames to newnames & value of cell ("I" & i as text)
else
exit repeat
end if
end repeat
end tell
end tell
close window 1
end tell
--loop through the files and rename them.
tell application "Finder"
repeat with k from 1 to (count of (get every item of theFolder))
repeat with i from 1 to count of oldnames
if (name of item k of theFolder) as text = (item i of oldnames) as text then
set name of (item k of theFolder) to (item i of newnames as text)
end if
end repeat
end repeat
end tell
i am brand new to this site and know very very very little about scripting, but i have a similar need where i must convert one 2 part file name to another 2 part file name. I have the codexes set up in excel, but have no idea how to tell my computer (24" iMac running 10.6.8) “hey imac, take the the files in these folders and change the names according to the codex in this excel spreadsheet”
any help? i may need to be walked through step by step if anyone would be so kind (though not a programmer, im completely computer literate, so i promise it wont be painful).
thanks in advance!
Model: 24" Intel iMac
Browser: Safari 534.50
Operating System: Mac OS X (10.6)