Before posting this topic I did a search on the forum using “Renaming files” and I have been unable to find the correct answer to my question.
Here is the situation
I’ve got a folder called “Macintosh HD:Users:DPaquin:_RenamingFileFolder” which contains mp4 files. For each of the mp4 files contained in that folder I need to change the first four characters (M2U0) to YTB0.
For examples :
- M2U04707.mp4 —> YTB04707.mp4
- M2U05502.mp4 —> YTB05502.mp4
- M2U03107.mp4 —> YTB03107.mp4
At the moment I am getting the following error message error “Can’t get every file of "Macintosh HD:Users:DPaquin:_RenamingFileFolder:".” number -1728 from every file of “Macintosh HD:Users:DPaquin:_RenamingFileFolder:” on the Tell application “Finder” call.
I cannot see what the error code -1728 is. However, I do no know the folder _RenamingFileFolder does exist.
As per the rest, I wrote the following code. I will try to find an answer to my error message. However, does anyone believe my code will be working?
THANKS AGAIN for your help!
Daniel
set RenameFilesWithinFolder to (path to home folder as text) & "_RenamingFolder:"
tell application "Finder" to set FilesToBeRenamed to files of RenameFilesWithinFolder whose name extension is "mp4"
repeat with i from 1 to count FilesToBeRenamed
set ValidPartName to characters 5 thru 12 of item i
set ValidName to "YTB0" & ValidPartName
tell application "Finder" to set name of item i to ValidName
end repeat