Home / Microsoft / Microsoft DOS / [SOLVED] Batch single command---multiple times. How?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: [SOLVED] Batch single command---multiple times. How?  (Read 1009 times)
MrFreePress
Topic Starter
Starter



Posts: 3


« on: September 13, 2009, 12:13:53 PM »

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.
« Last Edit: September 13, 2009, 01:34:33 PM by MrFreePress » IP logged
billrich
Guest
« Reply #1 on: September 13, 2009, 12:51:27 PM »

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


)
« Last Edit: September 13, 2009, 01:19:34 PM by billrich » IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #2 on: September 13, 2009, 01:27:33 PM »

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

IP logged


Proud to be European
MrFreePress
Topic Starter
Starter



Posts: 3


« Reply #3 on: September 13, 2009, 01:34:11 PM »

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.  :)
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #4 on: September 13, 2009, 02:28:04 PM »

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.


IP logged


Proud to be European
MrFreePress
Topic Starter
Starter



Posts: 3


« Reply #5 on: September 13, 2009, 02:42:23 PM »

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. :)
IP logged
billrich
Guest
« Reply #6 on: September 13, 2009, 03:25:23 PM »

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.
IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #7 on: September 13, 2009, 03:35:03 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.
IP logged


Proud to be European
billrich
Guest
« Reply #8 on: September 13, 2009, 03:39:33 PM »

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.

IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #9 on: September 13, 2009, 03:44:20 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?




IP logged


Proud to be European
billrich
Guest
« Reply #10 on: September 13, 2009, 04:01:33 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.
IP logged
BatchFileBasics
Hopeful



Thanked: 18
Posts: 387


BatchFileBasics
« Reply #11 on: September 13, 2009, 04:22:08 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 around
IP logged

When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #12 on: September 14, 2009, 12:18:39 AM »

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.
IP logged


Proud to be European
billrich
Guest
« Reply #13 on: September 14, 2009, 04:55:18 AM »

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.
IP logged
gh0std0g74
Apprentice



Thanked: 37
Posts: 590


« Reply #14 on: September 14, 2009, 05:26:25 AM »

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.
IP logged

Pages: [1] - (Top) Print 
Home / Microsoft / Microsoft DOS / [SOLVED] Batch single command---multiple times. How? « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.094 seconds with 20 queries.