1.

Solve : [SOLVED] Batch single command---multiple times. How??

Answer»

I feel like a newbie. I've not played with batch files in 20 years.

My OS: Windows XP
I'm using Windows build of http://www.speex.org/ as my command line.

I can successfully, at command promt, ONE at a time convert file:
speexdec 01.spx to 01.wav
The above results in a playable .WAV file that was a .SPX audio file.

MY GOAL:
In batch file I wish to convert 49 files from .spx to .wav(incrementally named 01.spx to 49.spx) as in the above command line example.

I know it is easy to do, with the right knowlege. I've been working on this for 2 hours and cannot locate the right variable/batch process to make this work.

Your help is greatly appreciated.Try a for loop with original file names in a text file:

I could not test the following code. I don't have the speexdec program. I do not have the files placed in the speed.txt file. I don't have the speed.txt file.
( you may post a few lines from the speed.txt file. )

For other options google [ convert spx to wav ]

Code: [Select]@ echo off

setLocal EnableDelayedExpansion

cd \

dir /s /b *.spx > speed.txt
set /a c=0


for /f "delims==" %%a in (speed.txt) do (

set /a c+=1
speexdec %%a to !c!.wav


)No need for a text file.

Convert EVERY .spx file in a folder to a like named wav file:

Code: [Select]@echo off
for /f "delims==" %%F in (*.spx) do speexdec "%%~dpnF.spx" "%%~dpnF.wav"
Or some other ideas here:

http://www.hydrogenaudio.org/forums/index.php?showtopic=55390

Thank you both.
Neither seemed to work but it did get me thinking about 'For' statements.
After a little more digging I got the following to work successfully.

for %%A in (*.spx) do (
speexdec "%%A" %%A.wav
)

I don't really understand what each part does but I SCRAMBLED long enough to put parts together. With that syntax, you should be getting the wav file being the spx filename + extension with .wav tacked on the end

e.g.

abc.spx ---> abc.spx.wav

whereas speexdec "%%~nA.spx" "%%~nA.wav" would give abc.spx ----> abc.wav

the ~dpn syntax means "drive and path\filename" (without extension)

so "%%~dpnA.spx" means "drive and path\filename.spx"

The quote marks are not compulsory unless a filename has one or more spaces.


You are absolutely right.
The resultant file was 01.spx.wav

Instead of fixing the syntax i simply pulled out my mass file renamer and renamed to what I needed.

I'll make note of your suggestion for next time.

Thanks again. Code: [Select]author=Salmon Trout link=topic=91835.msg621187#msg621187 date=1252870053]


Convert every .spx file in a folder to a like named wav file:
What if the .spx files are not all in the same folder? What if some .spx files had been placed in another folder on 02/04/2008? It would be nice to find the lost files. Quote from: billrich on September 13, 2009, 03:25:23 PM

What if the .spx files are not all in the same folder? What if some .spx files had been placed in another folder on 02/04/2008? It would be nice to find the lost files.

Let's wait for the OP to ask for the help that he or she actually requires.
Mr Trout wrote:
Quote
Let's wait for the OP to ask for the help that he or she actually requires.

You may wait if you like.

If all the original files did not have SEQUENCE numbers in the file name my code adds the squence number. Nice touch.

Quote from: billrich on September 13, 2009, 03:39:33 PM

If all the original files did not have sequence numbers in the file name my code adds the squence number. Nice touch.



I didn't see where he asked for that. Unnecessary touch.

Please do not call me "Mr Trout" unless you really are intending to start an argument, OK?




Quote from: Salmon Trout on September 13, 2009, 03:44:20 PM


Please do not call me "Mr Trout" unless you really are intending to start an argument, OK?


Ok, I call you Fishman.

You code is very compact and efficient. Very difficult for most of us new people to decipher. But code is for show not for ease to understand or use.Quote from: billrich on September 13, 2009, 04:01:33 PM
Ok, I call you Fishman.

You code is very compact and efficient. Very difficult for most of us new people to decipher. But code is for show not for ease to understand or use.

bill you are just being rude and humorless. and weird, i thought code is for use. not the other WAY aroundQuote from: BatchFileBasics on September 13, 2009, 04:22:08 PM
bill you are just being rude and humorless. and weird, i thought code is for use. not the other way around

I agree with both parts of the above, but I suppose Billrich raises a point that needs answering, even if only to demolish it. I always thought of this forum as a help forum where people post a question and other people suggest solutions. If I answer in a thread I therefore suggest bits of code which I have tried out which do the job. The code I post is not primarily intended as a teaching aid or an educational resource. Although batch coding is not rocket science!!! If it is "difficult to decipher" then I would suggest more study is needed.

Quote
You code is very compact and efficient.

I take that as a compliment; I don't see the point of adding lines that aren't needed, just because some folks find terse code frightening, although I will break code down and explain it step by step if asked, and if I have the time.S.T. wrote:

Quote
I don't see the point of adding lines that aren't needed, just because some folks find terse code frightening, although I will break code down and explain it step by step if asked, and if I have the time.

S.T. is such a nice guy. S.T. not only helps the original poster but all the new readers and students. And S.T. is so humble.Quote from: BatchFileBasics on September 13, 2009, 04:22:08 PM
bill you are just being rude and humorless. and weird, i thought code is for use. not the other way around
code is for use AND be maintained. when you maintain code, its best that code is readable and understandable without having to spend 10 minutes finding out what one expression means.


Discussion

No Comment Found