Can Applescript help me rename?

I have one folder with several mov files each with a different name.
I also have 2 text files in the same folder.
ORIGINAL.txt file with the current mov filename in the folder.
RENAME.txt file with the replace names for each file.
These 2 files I exported from FILEMAKER PRO hence I assume they are in the same order.
How can I rename the first movie file, whose name appears first in the ORIGINAL.TXT file with the first name found in the RENAME.txt file?
All movies are in the same folder and they are about 1027 … too many to do it manually.
Both the new names and the original filenames are unique so there should be no problems.
The original names in the all in the ORIGINAL.txt file end with the “.MOV” extension in big caps.
I hope very much for help.
Thanks in advance.

Hi,

try this, it assumes that both original and rename file names contain the .MOV ending
and there is one name per line.

It’s untested but it catches the errors if the length of the lists doesn’t match and if a file couldn’t be found


set projectFolder to (choose folder) as text
set originalFileNames to paragraphs of (read file (projectFolder & "ORIGINAL.txt"))
set renameFileNames to paragraphs of (read file (projectFolder & "RENAME.txt"))
if (count originalFileNames) = (count renameFileNames) then
	set errorList to {}
	repeat with i from 1 to (count originalFileNames)
		try
			tell application "Finder"
				set theFile to alias (projectFolder & item i of originalFileNames)
				set name of theFile to item i of renameFileNames
			end tell
		on error
			set end of errorList to item i of originalFileNames
		end try
	end repeat
	if (count errorList) > 0 then
		set {TID, text item delimiters} to {text item delimiters, return}
		set failedFileNames to errorList as text
		set text item delimiters to TID
		display dialog "The following files couldn't be renamed:" & return & return & failedFileNames
	end if
else
	display dialog "count mismatch"
end if

Thanks as always Stephan … I will let you know how it goes
Kind regards