Welcome Guest

Pages: 1
Checking special Chars in Title
not.relevantPostMay 2, 2015, 04:11
Newbie
Posts: 7
Registered:
May 2, 2015, 07:55
Normal topicChecking special Chars in Title

Hi folks,

I tried to do write an action, to clean the Title tag.

1. Cut off al leading and trailing spaces -> that was easy.
2. Check if the Title ends with one of these chars: !?)]
2.a If not ending on one of the above chars -> Cut off non alphanum chars
2.b If ending on one of these chars -> Prompt a message

The test with a title like "Will it Work?" failed. But why? Any ideas?

thanks
n.r.

Trim the Title field (SP) [Leading] [Trailing]

Test if the Title field ends with ")" (Or result)
Test if the Title field ends with "]" (Or result)
Test if the Title field ends with "!" (Or result)
Test if the Title field ends with "?" (Set result)

if false
Trim the Title field (Non A#) [Trailing]
else 
Prompt Character found! UI
endif

Edit: Interessting! If the same action runs grouped within another action it brings the correct message, when a char was found.
Strange or am I missing something else?

2MR2PostMay 2, 2015, 06:45
Avatar photo
Administrator
Posts: 2085
Registered:
August 23, 2012, 19:27
Normal topicRe: Checking special Chars in Title

Almost got it right 🙂 Two small issues.

The first is a 'Yate'ism. You have to remember that unless told otherwise a Yate action executes stepwise. That means that each statement is executed in parallel for each selected file. The 'Compare Text Test' statement only returns true if the associated test is "true for all files". You really want the entire action to run completely on a per file basis. (This might result in more than one prompt). As you want to execute all statements as a single unit for each selected file, you need a Force Grouped statement.

The second issue is the order of the Set and Or options on the tests. The first 3 Test statements are ignored because the 4th Sets the result overwriting whatever came before. The first Test should be a Set so that it overwrites the previous action test state value, The following 3 should Or in the result because you want to "or with what came before".

Also, the UI option on the Prompt statement is meaningless as it is only examined when Batch Processing. (It is harmless though).

Try:

Force Grouped Execution
Trim the Title field (SP) [Leading] [Trailing]
Test if the Title field ends with ")" (Set result)
Test if the Title field ends with "]" (Or result)
Test if the Title field ends with "!" (Or result)
Test if the Title field ends with "?" (Or result)
if false
Trim the Title field (Non A#) [Trailing]
else
Prompt Character found!
endif

Only a few tweaks to get it to work. Good start 🙂

Here's a variant which accumulates the "Character found" prompts and issues it only once.

Set named variable 'matches' to ""
Comment The following Run forces the Grouped requirement
Run inline action 'Test a single file' grouped
Test if named variable 'matches' is not empty (Set result)
if true
Prompt Character found in:\n\n\<matches>
endif

Start Test a single file
Trim the Title field (SP) [Leading] [Trailing]
Test if the Title field ends with ")" (Set result)
Test if the Title field ends with "]" (Or result)
Test if the Title field ends with "!" (Or result)
Test if the Title field ends with "?" (Or result)
if false
Trim the Title field (Non A#) [Trailing]
else
Get Property File Name (with extension) -> Variable 1
Set named variable 'matches' to "\<matches>\n\v1"
endif

One other little hint. Remember that an action only operates on those files that are selected. If you want an action to automatically select all open (non hidden) files, give it the All Files property in the Action Manager.

not.relevantPostMay 2, 2015, 09:10
Newbie
Posts: 7
Registered:
May 2, 2015, 07:55
Normal topicRe: Checking special Chars in Title

Thanks for the quick answer.

I figured out by myself that the set-or-result works not the way i thought (-;
I will try your recommendations.

Anyway: YATE is a very nice and quite powerful tool - if you know how to operate it (-; <thumbs up!>

not.relevantPostMay 2, 2015, 13:23
Newbie
Posts: 7
Registered:
May 2, 2015, 07:55
Normal topicRe: Checking special Chars in Title

And here are the final results for those who are interested:

I did 4 separate actions - one for each tag I want to "clean up": Title, Album, Artist & AlbumArtist.
the only difference is the managed field. And it's on purpose, that each field brings up a separate prompt.
maybe I change this later, but for now it works fine. it should be simple just giving the information how many entries in each field have one of the "choosen" characters. with this action I clean all non-alphanum chars and if the last char was one of "!?)]." it is appended afterwards again.
so Titles like "The best song ever!!!" wil change to "The best song ever!".

Thanks for the helping hands. 🙂

Set named variable 'matches' to ""
# 
Run inline action 'Test a single File' grouped
Test if named variable 'matches' is not empty (Set result)
if true
	Prompt Character found in Title: \n\n\<matches>
endif
# 
Start Test a single File
Set named variable 'varTitle' to ""
Set named variable 'varTrack' to ""
Set named variable 'varChar' to ""
Trim the Title field (SP) [Leading] [Trailing]
Test if the Title field ends with "." (Set result)
if true
	Set named variable 'varChar' to "."
endif
Test if the Title field ends with ")" (Set result)
if true
	Set named variable 'varChar' to ")"
endif
Test if the Title field ends with "]" (Set result)
if true
	Set named variable 'varChar' to "]"
endif
Test if the Title field ends with "!" (Set result)
if true
	Set named variable 'varChar' to "!"
endif
Test if the Title field ends with "?" (Set result)
if true
	Set named variable 'varChar' to "?"
endif
Trim the Title field (Non A#) [Trailing]
Test if named variable 'varChar' is not empty (Set result)
if true
	Get Property File Name (with extension) -> Variable 1
	Copy the Track field to named variable 'varTrack'
	Copy the Title field to named variable 'varTitle'
	Set named variable 'matches' to "\<matches>\nCharacter \<varChar> in Track \<varTrack> \<varTitle> file: \v1"
	Append "\<varChar>" to the Title field
	Set named variable 'varChar' to ""
endif
Pages: 1
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.018 seconds.