Welcome Guest

Pages: 1
Learning to create an action - sorting out disc numbers.
cromPostSeptember 20, 2016, 09:07
Newbie
Posts: 9
Registered:
September 1, 2016, 13:55
Normal topicLearning to create an action - sorting out disc numbers.

I am loving getting organised with my tagging and am writing scripts to automate significant bits of my tagging workflow but I am missing some fundamental understanding about YATE scripting and could do with some help. Please don’t go to the trouble of creating this action for me but some guidance would help me enormously to understand the challenges I need to overcome and the way to script YATE in the future.

As part of my workflow I work through all files that I am importing and check that albums have correct disc information. I don’t use three figure track numbers (e.g. 102 to indicate track 2 of disk 1) but rather make sure that disc field is correct and since I have started to play with YATE I now need to check the "disc count” field to make sure that “e.g. 1 of 2” is correct. Furthermore, if there is only one disc in an album I remove anything in disc or disc count. So, thinking through what I need to achieve:

The script needs to:

1. Detect that multiple albums are selected and deal with them in one execution (I will use the same inconsistency checking that you wrote into the move/rename action that you created a few weeks back)
2. Check for any existing value of field: disc
3. Check for any existing value of field: disc count
4. Check for any appended disk number on album name (use the existing “set disc numbers from Album Name 2” action)
5. Check for any existing parent folder that might indicate disc (e.g. Numbers or disk/disc)
6. Check for three or more figure track numbers (use an alert to ask user whether it's OK to process – it might just be that there are over 100 tracks in the album)

So, at this point I should have a pretty good idea of whether a track is part of a single disc album or a multi-disc album and I can process it depending upon what variables are set:

1. If disc count is 1 and disc is 1 then remove all disc field values and skip everything else
2. If the album name or parent folder values are !=“” then assign values as appropriate
3. If the track has three digits then see if we can assign values as appropriate
4. If disc is empty but disc count is > 1 then see if we can get a value from album or parent folder values

I assume that I should run the script in grouped so that it will work through processing each file individually – sounds like the logical way to do it! But how do I make sure that YATE processes the whole album in the same way if we are only dealing with files. Or am I just complicating my thinking unnecessarily because the script will just work through each file processing it according to the rules and will maintain the albums that are already defined?

Specific questions:
1. The Disc of Calculation appears to populate the “disc of” field. There isn’t a ‘disc of’ field in the field list, so is this actually the "disc count" field?

I’ve had a go at starting this and I’ll carry on later but any feedback or pointers would be appreciated.
Cheers,
Crom

Force Grouped Execution
' Using grouped execution so that each track is dealt with individually (all lines executed for each file before looping around to next file)
Disc Of Calculation
' check if disc count is set and then see if disc count is set
Test if the numeric value of the Disc Count field == "1" (Set result)
Prompt Disc count "\[Disc Count]” Beep
‘I can use the AND function here in the test statement to avoid stacking if, then, else statements
'Prompt Disk of "\[Disc of]" Beep
if true
Test if the Disc field is not empty (Set result)
if true
Prompt \[Disc] Beep
Set the Disc and Disc Count fields to ""
endif
else
endif

2MR2PostSeptember 20, 2016, 09:31
Avatar photo
Administrator
Posts: 2086
Registered:
August 23, 2012, 19:27
Normal topicRe: Learning to create an action - sorting out disc numbers.

Disc Of is Disc Count. The Disc Of terminology is historic.... and the UI still says Of for space reasons.

Disc Of and Track Of will not worked grouped as they only make sense when working on multiple files. You will get an error at runtime, I'd rearrange to do the following:

' running stepwise
Disc Of Calculation
Run inline action 'Per Track Logic' grouped
' anything else that makes sense to run stepwise

' running grouped
Start Per Track Logic
.... grouped logic here

My suggestion is to test as you go along and do not wait for all your logic to be in place. The Dump Variables statement is essentially an old school Print statement for debugging purposes. Use it to test your logic as you go along.

I've released a document called 'Yate and the P Word' which is on the new Resources web page which replaced the Sample Actions web page. You can easily get to it from the Help menu. The document might help get you going.

You can also test the validity of statements for different execution modes from the context menu.

If you need any help, .... we're here.

cromPostSeptember 20, 2016, 18:16
Newbie
Posts: 9
Registered:
September 1, 2016, 13:55
Normal topicRe: Learning to create an action - sorting out disc numbers.

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

2MR2PostSeptember 20, 2016, 18:34
Avatar photo
Administrator
Posts: 2086
Registered:
August 23, 2012, 19:27
Normal topicRe: Learning to create an action - sorting out disc numbers.

My brain is just not wired to read the text. If you right click on the action in the Action Manager, you can then do a Smart Export. When asked for a Prefix, enter:

crom-

The prefix lets me find things in my whopping large list of actions. email me the produced file. I'll be far easier for me to look at in the action.

There is no support for the Delete key now for action statements. I'll see what it takes to add it. Actions support Undo so it shouldn't be too dangerous.

Pages: 1
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.02 seconds.