I’m trying to rename a load of files in a folder which is working fine, but when it comes accross a particular file name it tries to rename the file twice instead of moving onto the next file.
try
tell application "Finder" to set the source_folder to folder "Macintosh HD:Users:nik:Desktop:rename folder"
end try
repeat with i from 1 to number of items in source_folder
set this_item to item i of source_folder
set theextention to ".pdf"
set thefilename to the name of this_item
set thepagenemuber to characters 17 thru 19 of thefilename as string
set parta to characters 1 thru 4 of thefilename
set partb to characters 6 thru 8 of thefilename
set partc to characters 10 thru 11 of thefilename
set partd to characters 13 thru 14 of thefilename
set the name of this_item to thepagenemuber & "_" & parta & "_" & partb & "_" & partc & "_" & partd & theextention
end repeat
The file thats being processed twice has this file name: mrwk-sep-01-06-pobc.pdf it first renames it to the correct name: obc_mrwk_sep_01_06.pdf but instead of skipping onto the next file it tries to reprocess this file again giving the result: 06._obc__rwk_se__0.pdf. This seems to be a problem with the letter “o” as any other combination of letters works.
Please help!!!