I’d like to rename and move files in a very specific way. I’d of course pay for help with this if anyone is up for the challenge. I would like to:
Select files in finder manually
Right click and choose “Quick Actions > My Rename & Move Workflow”
If possible I would want to validate that the file names start with four digits and a space ("0000 ", "0100 " etc) and filter out all other files (if any) or return if no matches (validating that it’s an audio file is a great addition if it’s easy to do)
If there is a hashtag followed by digits at the end of the file name (right before the extension) then that should be removed (“0000 MIX#10.wav” would become “0000 MIX.wav”)
Get a popup window where I type a custom title and press ok
The title should be inserted at the beginning of the file name and a space should be added after the title (“0000 MIX.wav” would become “Custom Title 0000 MIX.wav”)
This step would be a huge bonus, but may not be possible: if an audio timestamp is found in the audio meta data, then add it to the end of the file name with a leading space (“Custom Title 0000 MIX.wav” would become something like “Custom Title 0000 MIX 01.03.02.04.06.wav”). If this is not possible I’d like to enter the timecode manually in the same window as 5. or a separate window right after it. If nothing is entered in the timecode field, nothing would be added at the end of the string.
Move the files to a folder called “Exports” that exist two levels above (“Custom Title 0000 MIX 01.03.02.04.06.wav” would be moved to “…/…/Exports/Custom Title 0000 MIX 01.03.02.04.06.wav”). If “Exports” doesn’t exist then create it
Thanks for any leads to how I can make this happen or who I may hire.
This is a solution for the steps 1 - 7 without gathering audio metadata.
Without knowing the intermediate folder names it’s rather impossible to move the files.
• In Automator create a QuickAction, from the “Workflow receives current” popup menus select “audio files” and “Finder”
• Add a “Run AppleScript” action
• Replace the entire code with
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions
property regularExpression : a reference to current application's NSRegularExpressionSearch
property NSNotFound : a reference to 9.22337203685477E+18 + 5807
on run {input, parameters}
set {text returned:prefix} to display dialog "Enter Title" default answer ""
if prefix does not end with space then set prefix to prefix & space
set {text returned:timeCode} to display dialog "Enter TimeCode" default answer ""
repeat with aFile in input
tell application "Finder"
set {name:fileName, name extension:fileExtension} to aFile
set validatedName to my validateName(fileName)
if validatedName is not missing value then
if (count timeCode) is not 0 then
set baseName to text 1 thru -((count fileExtension) + 2) of validatedName
set name of contents of aFile to (prefix & baseName & space & timeCode & "." & fileExtension)
else
set name of contents of aFile to (prefix & validatedName)
end if
end if
end tell
end repeat
return input
end run
on validateName(theName)
set nsName to current application's NSString's stringWithString:theName
if (nsName's rangeOfString:"^\\d{4}\\s" options:regularExpression)'s location() is NSNotFound then return missing value
return (nsName's stringByReplacingOccurrencesOfString:"#\\d+" withString:"" options:regularExpression range:{location:0, |length|:(count theName)}) as text
end validateName
The validation is performed with help of AppleScriptObjC and Regular Expression
Wow, amazing! Only one thing. I only want to enter the title and timecode once and apply it to all files. I guess something needs to be moved out of the repeat loop? Thank you!!!
Oh man, Hero!! Brilliant!
Is there a quick way to require the first popup to be filled out? Second can be left empty.
That should be the last tweak! Do you have a donate button somewhere? Thank you!
While I have you on the line. Do you know if there is a way to assign mac os shortcuts to quick actions in Mojave? Like select my files and hit cmd+option+r (or whatever) to run the quick action.