View Single Post
MacGrunt

 
MacGrunt's Avatar
 
Member Since: Aug 02, 2011
Posts: 17
MacGrunt is on a distinguished road

MacGrunt is offline
G'day

I'm assuming you are trying to rename a bunch of files using one open excel spreadsheet as the source of the filenames and that the new filenames are in column A (?)

Code:
set theFiles to choose file with multiple selections allowed
set NewNames to {}

--place enough values from excel file into a list
tell application "Microsoft Excel"
	tell active sheet of active workbook
		repeat with x from 1 to count of theFiles
			set end of NewNames to formula of cell ("A" & x)
		end repeat
	end tell
end tell
--rename the files
repeat with i from 1 to count of theFiles
	set NewName to item i of NewNames
	set ThisFile to item i of theFiles
	tell application "Finder"
		set name of ThisFile to (NewName & "." & name extension of ThisFile)
	end tell
end repeat
i haven't tested what will happen if the script runs into an empty cell.

you could also run this as a droplet instead by changing it like this :
Code:
on open theFiles
	-- delete the following line
	set theFiles to choose file with multiple selections allowed
	--add the rest of the script
end open
hope that helps a little

m.
QUOTE Thanks