Hello,
I’m working with a ugly Applescript I wrote, but there is much room for improvement with this work I need to do, and so I’m here at Macscripter.
I’ve got 150 CDs with 5 audio files on each CD, totaling 750 different files. These are radio shows from a non-profit that I need to rename, downsample, and put on a web site. On each CD, the files are named “1 audio track.aiff”, “2 audio track.aiff”, up to “5 audio track.aiff”. I need to move all the files from CDs to a hard drive and give them unique names.
So I get a CD in the drive, copy the files to the desktop, then run an (ugly) Applescript I wrote that prompts me for the new file name for “1 audio track.aiff”, changes it, and does that for the other four files, one by one, using the same code with hardcode for the original file names, not an incrementing loop.) I have a hard copy of the new file names.
Code repreated 5 times in script:
tell application "Finder"
set oldFileName to "1 Audio Track.aiff"
set ext to ".aiff"
set new_name to the text returned of (display dialog "New name for 1 Audio Track.aiff:" default answer "")
set the name of file oldFileName of folder "Audio" of desktop to "l&c" & new_name & ext
end tell
I’ve run a few CDs, testing my Applescript and figuring out a workflow (which also includes converting to mp3s, downsampling and adding mp3 ID tags, but I can batch process that in shareware).
But the deal is that the new file names are actually dates, so on ~75% of the CDs the new file names will be sequentially numbered; unless the dates happen to be at the end of a month. So what I’d like to do is write a script that will prompt me for a starting numerical date string, rename the first file with string and then increment the string by one and rename the other 4 files in sequence.
The first 4 characters of the new file names (l&c04 or l&c05 or l&c06, standing for the years 1804, 1805 or 1806) will stay the same, and the extension will remain aiff. It’s the last 4 digits of the file name that make up the date that will change. So the script would prompt me for the starting string, I’d enter as an example 0517, and then the script would rename the files like this: l&c040517.aiff, l&c040518.aiff, l&c040519.aiff, l&c040520.aiff, l&c040521.aiff.
I know how to change part of a file name, and do different loops, but not how to increment by one each time and apply that to a file name. A better script that automates the renaming would obviously save a huge amount of time and drudgery…
Thanks, Mark