I have a lot of files with their filenames being a date in the format of DDMMYYYY with extention .xls (example: “12012006.xls” with that date being 12 januari 2006)
Now that date is useless to me and I would like to rename them to YYYYMMDD with extention .xls (the same). The example from above would change into “20060112.xls”
Does anyone know of a automator automation that can change the dateformat? Or know a script that could do this?
any help would be very greatfull!
I wasn’t sure if I should put this in the Automator forum or the Applescript forum. Sorry.
you can use an Automator workflow with “Get Selected Finder Items” and the following AppleScript.
Please note that this script is very simple. There is no error trapping or checking the right format.
The filename is always expected in the same format (DDMMYYYY)
on run {input, parameters}
repeat with i in input
tell application "Finder" to set {fName, ext} to {name, name extension} of i
set yr to text 5 thru 8 of fName
set mn to text 3 thru 4 of fName
set dy to text 1 thru 2 of fName
tell application "Finder" to set name of i to yr & mn & dy & "." & ext
end repeat
return input
end run
or an AppleScript droplet:
on open theseFiles
repeat with i in theseFiles
tell application "Finder" to set {fName, ext} to {name, name extension} of i
set yr to text 5 thru 8 of fName
set mn to text 3 thru 4 of fName
set dy to text 1 thru 2 of fName
tell application "Finder" to set name of i to yr & mn & dy & "." & ext
end repeat
end open
Model: G5 dual 2,5 GHz
Browser: Safari 419.3
Operating System: Mac OS X (10.4)