Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
batch rename - Apple script
#1
I know someone here will have the way to do this.
I have a bunch of file names that I have screwed up naming for easy search.

IE: blah, blah, blah 3.30.21
Finder looks at the first number first.
I should have put the year 1st instead of the month.
So I'd have: blah, blah, blah 21.3.30 etc.
Or better still 21-3.30

I have numerous files of the same name from different years.
IE: 3.28.15, 5.17.15, 7.24.13 etc.

I have NameChanger, but that really won't do this function.....I don't think.
Anyone have a method or script idea or simple app that'll redo the dates?
“Art is how we decorate space.
Music is how we decorate time.”
Jean-Michel Basquiat
Reply
#2
A Better Finder Rename usually does all my heavy duty renaming.
Reply
#3
Not sure if this would be an answer to your problem but Name Mangler 3 might.
Reply
#4
Test this with Script Editor and a few dummy files in an open Finder window. Assumptions being made are that 1) there are no file extensions, 2) all files start with some text other than dates or periods and end with a space, and 3) all dates are in a format separated by periods.


tell application 
Finder
to repeat with anItem in front window's files as alias list
tell file anItem to set name to my manip(name)
end repeat

on manip(nameString)
set text item delimiters to space
tell nameString
set {dateString, nameString} to {text item -1, nameString's text items 1 thru -2 as text}
set AppleScript's text item delimiters to
.
set {da, mo, yr} to dateString's text items
set AppleScript's text item delimiters to
end tell
nameString & {space, yr,
-
, da,
-
, mo}
end manip
Reply
#5
I'll look at both apps and thanks for the script.
The files all do have extensions, but I remove and add after.
“Art is how we decorate space.
Music is how we decorate time.”
Jean-Michel Basquiat
Reply
#6
Marc.

I figured how to change the . after the year to a dash.
But ...

error "Can’t get item 3 of {\"fix\", \"ptx\"}." number -1728 from item 3 of {"fix", "ptx"}

which refers to:
set {da, mo, yr} to dateString's text items (you probably knew that).

ah, I figured the error of my way.
I had space and letters after the years.
I have to think my format thru.
Did most of 20 in the test.
Thanks,
“Art is how we decorate space.
Music is how we decorate time.”
Jean-Michel Basquiat
Reply
#7
The format 2021.04.01 works for all centuries.
No fooling.
Reply


Forum Jump:


Users browsing this thread: