I did search, with little success, but I am not figuring this out.
I am trying to find away to count back 7 characters from the end of a file name and then omit those text items, and then replace with .pdf.
For example:
Before filename: xxxxxxxxx000.pdf
After filename: xxxxxxxxx.pdf
or
Before filename: xxxx120.pdf
After filename: xxxx.pdf
Reason being: This is the final stage on a folder action script that is working off a filename created by someone scanning in a document. The scanner always appends a 3 digit number & “.pdf” to the end. I am actually just looking for a way to remove the 3 digit number appended before the “.pdf”
I am not sure why I just can’t count backwards on a character filename? I know this is wrong, but I don’t know why?
tell application "Finder"
try
set kFiles to every file of folder new_folder
repeat with currFile in kFiles
set thisName to name of currFile
set temp_filename to thisName
delete (text items -1 through -7 of temp_filename)
--display dialog new_name as string
set name of currFile to new_name
end repeat
end try
end tell