just get the name of the file, set the part u want to get rid of as the text item delimiter, and change the filename to the part of the name u want to keep, and then whatever you want to change the rest of it to, and then the file extension:
tell application “Finder”
set fileAlias to (choose file)
set filePath to fileAlias as text
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set fileName to last text item of filePath
set AppleScript's text item delimiters to "."
set theExtension to last text item of fileName
set fileNamePart1 to text item 1 of fileName
set AppleScript's text item delimiters to "CHANGEME"
set fileNamePart1 to text item 1 of fileNamePart1
set fileNamePart2 to "CHANGED"
set fileName to fileNamePart1 & fileNamePart2 & "." & theExtension
set AppleScript's text item delimiters to TID
set name of fileAlias to fileName
oh, I wrote that without reading ur message in full. It is much easier than what I just did:
tell application "Finder"
set fileAlias to (choose file)
set filePath to fileAlias as text
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set fileName to last text item of filePath
set AppleScript's text item delimiters to "."
set theExtension to last text item of fileName
set fileNamePart1 to text item 1 of fileName
set AppleScript's text item delimiters to "JAN09"
set fileNamePart1 to text item 1 of fileNamePart1
set fileNamePart2 to "JAN10"
set fileName to fileNamePart1 & fileNamePart2 & "." & theExtension
set AppleScript's text item delimiters to TID
set name of fileAlias to fileName
end tell
and if you need assistance turning it into a folder action, just reply.
I’m guessing that you don’t just want to change JAN09 to JAN10 but also FEB09 to FEB10 and so on. If you find and replace “09” with “10” that will do it but is there any chance that “09” will appear anywhere else in the file name?
What else can you tell us about the rules you want to follow for this? Is the “09” always the last two characters of the filename before the extension? Can “09” appear in the rest of the filename anywhere?
Sounds like you might want something more like (in pseudocode - sorry I don’t have time right now to work out the actual code):
Separate the filename from the extension
If the last 2 characters of the filename = “09” the set a string to characters 1 through the total characters minus 2
Final string = string you just made + “10” + “.” + extension.