This is helpful, thank you. I read that article this afternoon, it was really useful.
Having done some more reading I think my basic approach is going to be:
1) Create a list per album and then loop through the list finding out what the data should be changed to on a per album basis and then processing each file within each album. That way I'll be able to process multiple albums in one run.
I've spent some time on this, this evening - basically creating a list of the albums and cobbling together some existing script from elsewhere on this site to check for disk details in the album title or the folder name. I'd appreciate any feedback on the general approach or specifics 😉
Also, is there a way in the editor to just delete functions? Backspace doesn't do anything and right mouse is long-winded.
Here's the code so far (such as it is!)
' In order to have access to all the selected files, the action was designed to be run 'stepwise'. The next statement is used to make sure that the action is being run 'stepwise'. If it is not, an error message is issued.
Cancel if the current execution context does not support support Stepwise
Set named variable 'List_Albums' to ""
Set named variable 'Disc_Number_From_Album' to ""
Set named variable 'Disc_Number_From_Folder' to ""
Set named variable 'New_Album_Name' to ""
Set named variable 'Full_Disk_Details' to ""
Set named variable 'Disk_Details_Found' to ""
' Trim the fields to ensure that there are no leading or trailing spaces
Trim Title and 6 other fields (SP) [Leading] [Trailing]
' Build a list of albums that need processing
Build List with delimiter "⏎" in named variable 'List_Albums' from field Album (Sorted) (Case Insensitive) string delimiter "\~"
Dump snapshot, named variables. UI
' Loop through list to see if album name contains disk information
Repeat With named variable 'Each_Album' for the list in named variable 'List_Albums' (As found) string delimiter "\~" Run inline action 'Test for Disk details in title' grouped (once)
' END OF MAIN SCRIPT
Start Test for Disk details in title
Set named variable 'Disk_Details_Found' to ""
' check the album name for disc-related info using the variable each_info
Find all matches for regular expression ".*(disc|disk|cd) *([0-9]+)$" in named variable 'Each_Album', replace with "$2" to named variable 'Disk_Details_Found', case insensitive, set state
Dump snapshot, named variables. Prompt What's the album we're working on? UI
if true
' Disc-related info found in album name
Set named variable 'Disc_Number_From_Album' to "\<Disk_Details_Found>"
Dump snapshot, named variables. Prompt Found in album name UI
' Do the same search and this time extract the entire string so that it can be removed from the album field
Find all matches for regular expression ".*(disc|disk|cd) *([0-9]+)$" in named variable 'Each_Album', replace with "$1 $2" to named variable 'Full_Disk_Details', case insensitive, set state
if true
Find "\<Full_Disk_Details>" ignoring case in named variable 'Each_Album', remove it and everything after
Set Variable 1 to "\<Each_Album>"
' **TODO: Probably should do a manual check to cover off any stray punctuation
Prompt for Text "The disc number has been stripped from this album title. Please check that the album name is correct." save text (Variable 1) to Variable 1 (Blue) Beep
Set named variable 'New_Album_Name' to "\V1"
Dump snapshot, named variables. Prompt Rename album to UI
endif
else
' check the Parent folder name for disc-related info
Get Property Folder Name -> Variable 1
Find all matches for regular expression ".*(disc|disk|cd) *([0-9]+)$" in field Variable 1, replace with "$2" to field Variable 1, case insensitive, set state
if true
# Copy the Variable 1 field to the Disc field
Set named variable 'Disc_Number_From_Folder' to "\V1"
Dump snapshot, system, named variables. Show Action Test State and Call Stack Prompt Found in folder UI
endif
endif
' End of Test for Disk details
|