|
#1
|
|||
|
|||
|
Batch File Coding
Hey guys,
I'm trying to write a batch that will decode all the mp3's in some dir. Here is what I have so far: for %%f in (*.mp3) do lame --decode "%%f" %f:~0,-4%.wav However, that last part (that makes is exclude .mp3 from the file name) doesn't work, even though the good ole documentation says it should. Anyone have any ideas?
__________________
Sanity is for the weak. |
| Sponsored Links |
|
#2
|
||||
|
||||
|
That %%f is being used as a special variable: the loop variable. As you can see it has a different syntax already: instead of %envvarname%, it's called %%x; percent mark only in the front and only a single letter allowed.
Mind you, DOS/Windows batch language is a completely ill-designed pile of shit. There's an alternative called 4DOS and 4NT but it has its own, "proprietary" language. When I do batch files I use GnuWin32, the native 32-bit Windows executables of the standard GNU tools (from Unix). (If you need the EXE's only, tell me.)With the GNU tools, it's not much easier, though - again, because of the incredible clumsiness of the DOW/Windows batch language: - As the inside of the loop consists of several instructions, you gotta make a subroutine. Such a construct cannot be defined in batch files, therefore, you need to make the batch file call itself as some kind of poor man's subroutine call. - You need to enclose filenames into quotation marks so that filenames with spaces inside won't get split apart and processed as multiple command line parameters. However, the batch file does get the quotation marks, as well. If you try to compare strings that may possibly have spaces inside, you need to enclose them into quotation marks, otherwise you'll get a syntax error; "IF whatever this file name is == whatever" just doesn't work! However, if the string is already enclosed into quotation marks - because that's how you passed it to the batch -, you'll just unquote them and get back to the previous problem. Therefore, I use no spaces in filenames (convert them to underscores instead)! - You cannot execute a command and then include its standard output as part of another command. This means, you cannot set an environment variable to a value that arrives via the standard output of a command. Therefore, you gotta create a temporary batch file, with a SET command in it, append the standard output of the command to this batch file and run the batch file, to have the value put into the variable. UGLY! It's worth learning how to use the standard GNU tools as they are a standard, well-designed, continuously maintained sets of general purpose tools, and they will come very handy anyway if you need to switch to Unix some time (i.e. when Micro$oft gets bankrupt and Linux will become the only major OS in town, HAHAHA! ).As for the actual problem, here's a sample batch file for you; it may give you syntax errors, though, I haven't tested it. I'm currently into DVD-ripping with GordianKnot and have developed quite a few similar, but much more complicated batch files - for automized audio conversion with BeSweet or LAME - that use the GNU tools and work similarly to GNU tools (with respect to command line options). If you're interested, contact me via E-mail! if `%1` == `` goto all echo `%1` | tr -d "\042`" | sed "s/\.mp3$/.wav/I;s/^/set INPUTNAME=/" > %TEMP%\whatever.bat call %TEMP%\whatever.bat del %TEMP%\whatever.bat lame --decode %1 "%FILENAME%" :all for %%f in (*.mp3) do call %0 "%%f"
__________________
Joe Forster/STA For more information, see the FileForums forum rules and the PC Games forum FAQ! Don't contact me via E-mail or PM to ask for help with anything other than patches (or software in general) done by me, otherwise your request may be deleted without any reply! Homepage: http://sta.c64.org, E-mail: [email protected]; for attachments, send compressed (ZIP or RAR) files only, otherwise your E-mail will bounce back! Last edited by Joe Forster/STA; 10-04-2006 at 03:51. |
![]() |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| LotR:BfME noDVD 1.02 question | kenmeller | PC Games | 18 | 13-04-2006 04:56 |
| cd burner help | snatchcrash | CD/DVD-Writers | 1 | 14-09-2002 04:32 |
| My .iml file of Gran Turismo 3 is just 16KB big and iml2iso doesnīt work. | Kai-G | PS2 Games | 4 | 22-09-2001 06:39 |
| I need help to burn DC games | Puppydawg | DC Games | 4 | 26-07-2001 11:38 |
| i know nobody likes the new people, but ill try anyway.. | BWeb | DC Games | 3 | 25-07-2001 06:44 |