Command: JoinMP3

It does show as type is Standard.
I think it needs to be changed to scripting, but the the comments are wrong styled.
maybe @fred can actually copy/paste his button

I see there is a line "@script VBScript", remove that and try again. It should not be there.

1 Like

Thanks! That fixed it!

I've edited Fred's post above to clarify that it should be pasted into a Standard Function button, not a Script Function button.

Pasting into the wrong button type will be where the extra @script jscript line came from; it was not in the original code.

I've removed the duplicate copy of the code from the previous post to avoid confusion & save people wondering what the difference is. (At least, I think the two were the same code, just one in XML format and one not.)

I would think the button code is better, as it's more user friendly,
It has the names and tooltips already defined, a useful icon?, and easier to install
versus just the script contents.

Plus I had made some changes by removing the override on the EXE & PAUSE parameters of JoinMP3, that way the definition of the script takes precedence rather than the button, else the script won't work in other places than the button.

I recall pasting in a standard button only, but i could be wrong. Maybe i switched between the types when i saw the comment lines weren't getting highlighted in the standard button code, and that might have added the errant line of code.

It is slightly (although also harder to read), but not enough to offset the user-unfriendliness of having two near-identical versions of the same thing in one thread which people have to choose between, and where the original author cannot update one of them.

Any way to make the script work on folders of mp3s?
image

example above, convert a bunch of folders into mp3, by finding all mp3 files in them and converting to one mp3 with the folder name?

I saw in the script that it only expects files.

function Command_JoinMP3(data) {
	DOpus.Output("JoinMP3:");
	var files = GetFiles(data);
	if (!files || files.count==1){
		DOpus.Output("Not enough files given.");
		return false;
	}
	data.func.command.ClearFiles();
	data.func.command.SetType("msdos");


Function Getfiles only checks for files.

function GetFiles(data){
	if (data.func.args.got_arg.files)
		var files = data.func.args.files;
	else if (data.func.sourcetab.selected_files.count)
		var files = data.func.sourcetab.selected_files;
	else
		var files = data.func.sourcetab.files;
	return { enumerator:new Enumerator(files), count:files.count};
}

I am guessing we could create a loop and call JoinMP3 command in the button
OR
modify the script to accept both files & folders as input

Switching into flat view and selecting all mp3s from the subfolders could work as well.

This MS-DOS button will concatenate all .mp3 in selected folders, producing one file per folder, named foldername.mp3.

@nodeselect 
@dirsonly
@nofilenamequoting

(for %%i in ("{filepath}*.mp3") do @echo file '%%i') > ffmlist.txt
ffmpeg.exe -f concat -safe 0 -i ffmlist.txt -c copy "{filepath|noterm}.mp3"

pause

(I only skimmed the thread, apologies if I missed something)

1 Like

I tried that but it didn't create a single file for each folder, but combined all into one.

Will test later, and confirm results

This version should work better:

@nodeselect 
@dirsonly
@nofilenamequoting

(for %%i in ("{filepath}*.mp3") do @echo file '%%i') > "{filepath|noterm}.txt"
ffmpeg.exe -f concat -safe 0 -i "{filepath|noterm}.txt" -c copy "{filepath|noterm}.mp3"

pause
1 Like

Works perfectly! Thanks :+1:

Now I am just curious as to how I can integrate it with the existing script, but not required.

everything works (thanks sir lxp!) but both the intermediate txt file and the mp3 file end up without names.

Just .txt and .mp3

Any idea why?

{filepath|noterm} is a directory, adding ".mp3" creates something like "...mp3", so the filename is just missing in the expression. From the top of my head, using "{filepath|noterm}{file|noext}.mp3" could work (same for the *.txt expressions).

I guess you selected the mp3 files directly. The script expects you to select folders and will then concatenate all mp3 files it finds in them.

Ah. It does work when the parent folder is selected. I was running the script while the folder was open, mp3s were visible, and nothing was selected.

I noticed that single quotes in the folder name crashes the script. For some reason it can't find the intermediate text file after creating it perfectly fine.

For Ffmpeg single quotes are delimiters, not characters.