简体   繁体   中英

How to automate a file conversion xwm to mp3 with xwmaencode.exe using bat file

the code that is required to run this is: xwmaencode.exe .xwm . I wanna make a .bat file that can allow me to drag and drop a file or convert all of the .xwm files within the current folder to .mp3 preferrably

an explanation of each part would be good as well, i have no clue how .bat files operate, and i have limited knowledge on CMD syntax, but i can manage

if you don't mind file.xwm.wav (and there are utilities out there that'll remove the .xwm*), what i did was basically taken from PNGOUT.exe's help examples:

for %i in (*.xwm) do xwmaencode %i %i.wav

in this case, you don't have any files with spaces, but if you did, you'd do

for %i in (*.xwm) do xwmaencode "%i" "%i".wav

*powershell might, but i have no idea

I'm not sure about the exact code for the xwmaencode code line, for I don't know the tool but a quick look at the readme of xwmaencode tells me that this should work:

@ECHO OFF
:TOP
IF (%1) == () GOTO END
ECHO Processing %1...
REM you will need to modify the next line
C:\Path\To\xwmaencode.exe %1 %1.mp3
SHIFT
GOTO TOP
:END
ECHO All files processed!
PAUSE

When you d&d a file onto a bat the complete path to the file is passed to the bat as a parameter: batfile.bat path:\\to\\dragged\\file\\file.xyz

If you d&d several files it looks like this:

batfile.bat path1 path2 path3 ... pathN

You can access the first parameter (meanst the path to the first file) with %1, to the second with %2, etc. By calling SHIFT you move %1 from the first paramater to the second. So the code is in a loop calling xwmaencode.exe with %1 and shifting %1 to the next parameter after each execution. It stops as soon as %1 is empty.

The above ought to work, but variables in batch files need to be defined with two percent signs, not one. (Eg, %%a instead of %a) Also, taking away the @ECHO OFF line will let you see if the command worked or any errors it gives you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM