Run a TOOL Command, based on selection, in a SINGLE WINDOW

What do you expect the scripts to do?
What is the contents of %mp3propedit_freeform%?
How is the script unsuccessful?

You must be more specific when asking for help! :slightly_smiling_face:

But for starters, you forgot the single quotes when you changed "%creation_time%" to "%mp3propedit_freeform%" in Line 28

SelectedFilesDictionary.Add "'%_path%'", "%mp3propedit_freeform%"'
Should be:
SelectedFilesDictionary.Add "'%_path%'", "'%mp3propedit_freeform%'"'

%mp3propedit_freeform% should contain the complete command line arguments, except for the file path. Hopefully, that is true.

My apologies for being vague. Usually, I am very detailed, but I guess I am doing a poor job. Nonetheless, thanks for responding. As for what I am trying to accomplish, from the first image attached, titled "Free-form objective.png," which works using the 3-line code you prescribed, it's a failure when I attempt to perform that same task using VBS-script. Moreover, as for the second image, titled "Line 28 Error.png," the error appears after your recommendation of returning line 28 to match the same format as the first VBS script that you sent me regarding the creation time. SelectedFilesDictionary.Add

"'%_path%'", "'%mp3propedit_freeform%'"'


Basically, what I am trying to achieve, that has already been achieved via your 3-line code, is that I can implement a command line such as --edit track:a1 --set flag-default=1 --edit track:s1 --set flag-default=1 --set flag-forced=0 --set name="English: Signs/Lyrics" --set language=eng --edit track:s2 --set flag-default=0 --set flag-forced=0 --set name="Full Translation" --set language=eng, in the %mp3propedit_freeform% field, and mkvpropedit.exe will actually run and fulfill the command. This works using your 3-line code, which I am very grateful for, but it's unsuccessful when I attempt it using VBS-script. I believe the problem likely comes from Line 35 because from the first VBS script you sent to me, Line 35's CommandArguments = "--edit info --set date=". However, it's not applicable for this command line because I am not trying to change the date. I hope I am being as detailed as possible lol. And thanks again for responding.

Don't worry about it. It is sometimes difficult to ask succinct questions with all the necessary information. :wink:
Your new command line contains double quotes and I suspect they are not handled properly by my script.
I will do some investigation and testing to figure out a solution, then reply again.

thank you, sir. I appreciate it

Double quotes were the issue.
I have enough trouble with them in VBS scripts alone, never mind trying to write a VBS script with the Mp3tag MTE script language. :slightly_smiling_face:
If the attached script fails, I may need a copy of one of your MKV files for further testing.
You can post a link to a file sharing service.

And here's a "heads-up": single quotes have a special function in Mp3tag scripting so they might need special handling to be used literally.

CORRECTED_Jan11_2022_VBS script_MKVPropEdit_ FREE FORM.mte (1.8 KB)

It worked. Thank you so much. I really appreciate it. There is no way that I would have been able to figure it out, given the fact I just glanced at your corrections. All of this could have been avoided if Mkvmerge.exe had a command line to preserve the original "Encoded date" because when it comes to handling mkv files, mkvtoolnix (mkvmerge.exe, mkvpropedit.exe), in my opinion, surpasses FFmpeg :grinning:. Nonetheless, thanks again. I really appreciate the help.

1 Like

One more question, if I wanted to include MKA as a list of extension for the script to read, how do I go about modifying Line 27 in the VBS script you just sent me?

' if LCase("'%_extension%'") = "mkv" then'

Never mind, I figured it out below:

' if LCase("'%_extension%'") = "mkv" OR ("'%_extension%'") = "mka" then'

1 Like

Good. :+1:
But the comparisons are case sensitive, so you might want to use the "Lower Case function", like this:
' if LCase("'%_extension%'") = "mkv" OR LCase("'%_extension%'") = "mka" then'

Thank you, sir. Hope you don't mind me, in the future, asking you for assistance because it was pure luck that I managed to insert multiple extensions :grinning:. Thanks, again

Sure, I'm happy to help.
For issues that do not concern Mp3tag, we should use the "Off-Topic" section or maybe the forum's "Message" system.
This thread started OK, but we are now getting into non-Mp3tag areas. :slightly_smiling_face:

Yes sir. Thank you, and I will do that the next time

Good evening, sir. On this page, you authored a VBS script for me early January of this year, CORRECTED_Jan11_2022_VBS script_MKVPropEdit_ FREE FORM.mte, and I was wondering if you would be able to verify if I correctly implemented my second argument, located on Line 45, after the first argument on Line 28, or is there a way to implement both arguments on Line 28 because piping was unsuccessful, and I did not want to create another .mte file? Thus, the modified script, from your original, works flawlessly, but I just wanted verification from you concerning if I am moving in the right direction of adding a secondary argument? Likewise, the intended script was supposed to be -c "%win_create_date%" -m "%win_modify_date%", but WinTestGear_FileTouch.exe only recognized and changed the file modification date, while neglecting the creation date, which led me to separate both arguments, as seen in Lines 28 and 45. I attached my modified version of your VBS Script.

MODIFIED_WinTestGear's FileTouch v1.0.0.3 (Windows OS) (12-23-2009).mte (5.0 KB)

There is probably several other ways to do what your modified script does, but "If it ain't broke, don't fix it."
I don't know the format of whatever is in WIN_CREATE_DATE or WIN_MODIFY_DATE.
I used mm/dd/yyyy for testing and saw no problems.

If %win_modify_date% and %win_create_date% are the same for each file, you could combine the FileTouch.exe switches and eliminate the second loop.
But I guess you already knew that.

Indeed you are absolutely correct "if it ain't broke, don't fix it" lol. Nonetheless, not sure if you use FileTouch, but the one recommended to me via the mp3tag community, FileTouch command line utility, was insufficient because it required separation of date and time into separate fields. Thus, I found this one Download File Touch 1.0.0.3, and it works flawlessly when coupled with your VBS Script because, for example, if I wanted to illustrate September 1st 2027 9:25:00 AM, it can be represented like any one of these on an Mp3Tag field:

2027-9-1 9:25:002027/9/1 09:25:002027-09-01 9:25:00 AM 9-1/2027 09:25:009-1-2027 09:25:0009-01-2027 09:25:00September 1 2027 9:25:00September 1, 2027 9:25:00 AMSep 1, 2027 9:25:00 AM1 September 2027 09:25:001 Sep 2027 09:25:00

WinTestGear's FileTouch v1.0.0.3 (12-23-2009).zip (25.4 KB)

Thanks. That's the one I used for testing.
I couldn't find any documentation that explained what date formats were supported.
I used the format shown in the examples, but it is good to know that others are allowed.

You're welcome, sir, but I cannot take all the credit here because your VBS Script did wonders for it since without it, I would have to use the TOOLS option which will yield multiple windows. Therefore, thank you. Now, at my leisure, I will try to find a 3rd party command line program that can edit Windows Explorer File Properties "Details" tab for mp4/m4a on the Origins field (i.e. Directors, Producers, Writers, etc) because Mp3Tag seems to not support those fields, and houses them within the %itunmovi% tag field. If successful on my quest, I will post it here.

Good evening, sir. Apologies for bothering you once again. I was wondering if you can help me in regards to your .MTE file (my modification is attached below), concerning the implementation of FFmpeg.exe. Florian released a User-defined TOOLS parameter for ffmpeg.exe ➤➤ -i "%_filename_ext%" -c copy -metadata creation_time="%ryerman_mte%" -y "%_folderpath%\%_filename%_out.mp4", and it worked perfectly under TOOLS, but with multiple CMD windows on multiple files. However, when I tried to execute the same parameter under your .MTE file, it wouldn't execute at all. Moreover, when I included the placeholder, %_folderpath%, behind the %_filename_ext%, such -i "%_folderpath%\%_filename_ext%", changing the overall script to -i "%_folderpath%\%_filename_ext%" -c copy -metadata creation_time="%ryerman_mte%" -y "%_folderpath%\%_filename%_out.mp4", the command line parameter worked on the .MTE file, but it yielded a 32 KB mp4 output, and DESTROYED the ORIGINAL .mkv input file. The destruction of the ORIGINAL input file typically occurs when I employed, from Line's 28, SelectedFilesDictionary.Add "'%_path%'" or SelectedFilesDictionary.Add "'%_filename_rel%'". Likewise, it preserves the ORIGINAL input file when I substitute Line's 28, SelectedFilesDictionary.Add "'%_path%'" with SelectedFilesDictionary.Add "'%_directory%'", "'%_folderpath_rel%'", "'%_parent_directory%'", or "'%_workingpath%'", but yields a 0 KB mp4 output file. I believe the issue likely stems from placeholder(s).

ORIGINAL file Preserved_ FFmpeg with ryerman's FREEFORM VBS Script (July 2nd 2022).mte (3.1 KB)

Maybe.
But I think there are also fundamental issues that are causing problems.
I originally tried to create a VBS script that could be applied to different command lines.
I had assumed that all command lines have the same format, but that is not true.
The attached replacement uses a more generalized format that should accomodate any command line.
The tricky part is composing the command line.

The script, like any script, is easily broken, especially if you are not relatively competent in VBS scripting.
It's admirable that you tried to adapt the script to your own needs but perhaps you are unfamiliar with VBS scripting.
For example, all the keys in the dictionary data structure must be unique and an error will be raised if you attempt to add a duplicate.
Also, %_folderpath% includes a trailing backslash, so %_folderpath%\%_filename_ext% will expand with 2 backslashes before the filename.

I'm puzzled by all the file extensions you check for and allow, but that shouldn't cause an execution problem.
However, some of the MP4 files that are created were unplayable when I tested them using VLC.
Files converted from FLAC, TTA, WAV, WMA, WV and APE caused errors.

I have no idea how you populate %ryerman_mte%, so maybe the test string I used caused problems. Or maybe my files are corrupt in some way.

Anyhow, try the attached script.
EDITED (July 15, 2022) file Preserved_ FFmpeg with ryerman's FREEFORM VBS Script (July 2nd 2022).mte (3.6 KB)

Apologies, sir, for the late response. Nevertheless, your VBS Script, for FFmpeg, worked, in which, once again, I am very grateful. As for using your name as a format string, %ryerman_mte%, it's more to establish the VBS Script author. I believe this is the 3rd VBS Script that you wrote for me, and, in the 3rd one, it provided a more detailed message box regarding total number of files and commands processed, which I incorporated into your second VBS Script, my favorite one: mkvpropedit (%mp3propedit% as the format string). Believe it or not, your second VBS script has done more wonders than you could have imagined because I created .MTEs' of the script for Exiftool, WinTestGear's FileTouch v1.0.0.3, and NirSofer's Property System View. The only issue that I have with NirSofer's Property System View is that if an Mp3Tag FIELD contains double quotations, NirSofer's Property System View will only write into the Mp4 properties up to the first double quote, deleting everything else. I searched online on how to escape it as you would do for regex, but no luck.

As for your question regarding the multiple file extensions, which correlates with all the file extensions MP3Tag can read (excluding .mks), it was for WinTestGear's FileTouch v1.0.0.3 .MTE file to change the dates for various media types, and since ffmpeg can read practically almost every media, I thought it would be appropriate to use it as well. Nonetheless, thank you, once again, because you solved my MP4 problem regarding Windows Explorer File Properties, in which I used your 2nd VBS Script Template responding to someone else's post: RESPONSE to incorporate NirSofer's Property System View with Mp3Tag's .MTE file

Moreover, there is no way I could have figured it out for ffmpeg in LINE 30 of the VBS Script. Therefore, I was wondering if you could direct me to what guides (i.e. books, forums, et cetera) you used to learn how to write VBS Scripts because you are correct about the command arguments in LINE 30 being tricky, especially when to use single/double quotations as the last argument before the next & chr(34). For example, "'%ryerman_mte%"' vs "'%ryerman_mte%'", in which the first %ryerman_mte% is ended by a SINGLE quote, and the second %ryerman_mte% is ended by a DOUBLE quotation, as well as every line must end with an even-number of SINGLE quotes.

Lastly, thanks because, though I am not an expert like you nor DetlevD, whom, apparently, has been dubbed the father of .MTE files, I can comfortably write my own regex, given the .MTA file you wrote for me to convert format of date and time from, for example, 6/25/2022 11:25:33 PM to 2022-06-25 23:25:33. Thank you, again, sir, for your help and patience. I really appreciate it.

You are using ryerman_mte as the name of a field you have created to hold some information.

The name of a user created field is unimportant.
But nobody can read your mind with respect to how you populate a non-standard field.
When you're asking for help with a command line it is necessary to provide details of the data that it may contain.
A fully expanded, complete example of the command line is usually helpful.

If you always exported only files that are allowed by the external application, no check of file extensions is required.
Checking file extensions in these scripts assumes that you might export files that you do not want to process.
In other words, you can select all files without sorting beforehand and let a script process only the desired file types.
If a particular command line accepts any and all of the files that you allow to be loaded into Mp3tag, there is no reason to check file extensions.
Some applications (like mkvpropedit) expect certain file type(s).

In VBS, single quotes are used to signify comments: anything after a single quote is ignored at execution.
If a single quote is required for a file specification on a command line or anywhere not enclosed in double quotes, I use chr(39) instead.
In Mp3tag, single quotes are used to escape special characters.
In an export script, anything surrounded by single quotes is treated literally.
So single quotes surround the VBS statements/commands when using the export function to write a VBS script.
In your example of "'%ryerman_mte%'", the single quotes are not surrounding %ryerman_mte%.
If you examine the MTE script carefully, you will see that the first single quote is the trailing quote of the quotes surrounding the preceding part of the command.
And the second single quote is the opening quote of the quotes surrounding the following part of the command.

It is tricky because we must obey the syntax for VBS scripts while writing the VBS script using the syntax of MP3tag export scripts, all the while fullfilling the requirements of a particular command line.
I can't think of a foolproof rule that governs every case of when to use " or chr(34) or ' or chr(39).
That is why it is important to give a good example of the command line and to give details of the data that will be exported.
My usual procedure is:

  1. Compose a command line that works in the command processor.
  2. Create a VBS script that properly executes the command line.
  3. Create a MTE export script that writes the VBS script and adds the desired file data. That usually means looping through the file paths.

I didn't learn VBS scripting in any formal setting or online.
I did learn FORTRAN and BASIC, way back when I was young, so I am familiar with programming.
When I started using VBS, I was a "copy and paste" programmer: I would search online for a specific task and use whatever code I found.
I slowly learned some of the basics but I have little in-depth knowledge.
If you google "Learn VBS", you will find some information about online instruction.