Below is the code for a script to rename pdf files in sequencial numerical order. The script is a App, working by dropping a selection of pdf files onto it to initiate. The problem with the script is that sometimes (ie. not always), the script will start numbering with the 2nd file in the list of selected files, leaving the 1st file in the list until the last. The end result being the pdf numbers out of order. (The pdf files in my case are already numbered eg. 1 -10, but my client required that they by numbered as per id numbers in the file. Eg. 2100 - 2109). Why is the script starting with the 2nd file?? Would there be any benefit in writing a script to process a folder as opposed to individual files? I have not tried this but I would be happy to try if this will resolve the problem.
global pdfname
global origname
global timedelay
pdfstart as number
on open fileList
display dialog "What number do you to start at?" default answer ""
set pdfstart to text returned of result
repeat with aFile in fileList
tell application "Finder"
activate
set origname to name of aFile
select aFile
set name of aFile to (pdfstart as string) & ".pdf"
set pdfstart to pdfstart + 1
end tell
end repeat
end open