PDA

View Full Version : Batch Files - "How to" + Recipes (add 'em if you got 'em!)


feralicious
2005-03-20, 11:39 AM
So I found out how to make a batch file...

Right click desktop > new txt file > open this txt file > type in (cut and pasted one from uhclem) batch file recipe > save as "all files" with .bat extension.

Tested it and it works!

I thought it would be cool and helpful if people posted their recipes in this thread for those of us who don't know how to figure it out.

feralicious
2005-03-20, 11:41 AM
Flac Fingerprints
previously posted by uhclem:

I use a simple batch file to create the fingerprint. It's simple because you just drag 'n' drop the folder containing your new flacs onto the batch file and voila it produces a fingerprint file for you in the folder. Here's the batch file I use:

@<hidden> off
%~d1 & cd "%~1"
for %%F in (*.flac) do metaflac --show-md5sum --with-filename "%%F" >> "%~n1-ffp.txt"

pmonk
2005-03-20, 11:44 AM
Remember - that creates a text file. If you just want to do a quick (minus the text) just create a new batch files minus the text command!

@<hidden> off
%~d1 & cd "%~1"
for %%F in (*.flac) do metaflac --show-md5sum --with-filename "%%F"
pause

pmonk
2005-03-20, 11:46 AM
For a shntool md5

@<hidden> off
%~d1 & cd %*
for %%T in (shn flac wav ape) do if exist *.%%T shntool md5 *.%%T>>shntool.md5.txt
pause

pmonk
2005-03-20, 11:48 AM
shntool len

@<hidden> off
%~d1 & cd %*
for %%T in (shn flac wav ape) do if exist *.%%T shntool len -u mb *.%%T
pause

If you want to save it add the text command on the end!

feralicious
2005-03-20, 01:21 PM
shntool len with txt file added to folder

shntool len

@<hidden> off
%~d1 & cd %*
for %%T in (shn flac wav ape) do if exist *.%%T shntool len -u mb *.%%T
pause

If you want to save it add the text command on the end!played with the txt command from the ffp batch file and this seems to work to add the shntool txt into the folder:


shntool len with txt file added to folder:

@<hidden> off
%~d1 & cd %*
for %%T in (shn flac wav ape) do if exist *.%%T shntool len -u mb *.%%T >> "%~n1-shntool.txt"

Yay! :clap:

edit by U2Lynne: poster asked that batch file be corrected as per uhclem's comments below. We don't want to confuse anyone who doesn't read the whole post. ;)

feralicious
2005-03-20, 01:25 PM
Remember - that creates a text file. If you just want to do a quick (minus the text) just create a new batch files minus the text command!

@<hidden> off
%~d1 & cd "%~1"
for %%F in (*.flac) do metaflac --show-md5sum --with-filename "%%F"
pause
This didn't work for me. Well the cmd box opened and disappeared right quick with no trail left behind, so I assume it didn't work.

uhclem
2005-03-20, 01:32 PM
@<hidden> off
%~d1 & cd %*
for %%T in (shn flac wav ape) do if exist *.%%T shntool len -u mb *.%%T --show-len --with-filename "%%F" >> "%~n1-shntool.txt"
The part highlighted in red is an error. I don't know what it's doing there.

feralicious
2005-03-20, 01:37 PM
The part highlighted in red is an error. I don't know what it's doing there.Neither do I!!! :lol
But it worked. Ah... I think I had an apostrophe after the %%T when I didn't have the red part, and when I added the red part I got rid of that. So it's probably just sitting there looking pretty while the rest of it does all the work. I'll try without it.

Yep works fine without it. I'll ask a Mod to edit that post. Thanks.

Can you post a Batch file for fixing SBEs? I just checked a show and all files have them. :(

pmonk
2005-03-20, 02:31 PM
Can you post a Batch file for fixing SBEs? I just checked a show and all files have them. :(

IMO - just use Trader's Little Helper to fix SBEs. It does a fine job.

I do have a batch file for shntool sbe but I never used it so I don't think it is a good ise to post

Five
2005-03-20, 03:48 PM
the only thing with TLH fixing SBEs is if I only want to pad the last track. uhclem gave me a command for shntool to do this (haven't tried it, will post when I do), not sure if TLH can do that. I'm sure it will be able to in time.

pmonk
2005-03-20, 04:51 PM
No - TLH will not fix the silence on the end of the last track - you need to use shntool for that!

Five
2005-03-20, 04:56 PM
the convenient thing, too, is that if you've installed TLH you've also installed SHNtool. I copied the command for padding the final track with silence on my other computer, I'll post it here later on.

pmonk
2005-03-20, 05:16 PM
Well - I just downloaded this from eztree (shocking) and this is what I got when I ran the shntool len report

ELECTRIC LADY STUDIOS, NEW-YORK
JUNE 25 & 26 + JULY 23 1970

The directory name is invalid.
length expanded size cdr WAVE problems filename
3:50.41 40668476 --- -- ---xx Track01.flac
0:55.16 9740528 -b- -- ---xx Track02.flac
0:22.71 4047836 --- -- ---xx Track03.flac
4:02.53 42813500 --- -- ---xx Track04.flac
6:29.08 68638460 --- -- ---xx Track05.flac
4:35.59 48648812 --- -- ---xx Track06.flac
12:48.13 135505416 -b- -- ---xx Track07.flac
21:19.38 225705424 -b- -- ---xx Track08.flac
3:32.49 37512092 --- -- ---xx Track09.flac
1:25.34 15074012 --- -- ---xx Track10.flac
0:25.74 4584092 --- -- ---xx Track11.flac
4:43.64 50071772 --- -- ---xx Track12.flac
0:33.05 5833004 --- -- ---xx Track13.flac
3:39.71 38798636 --- -- ---xx Track14.flac
4:19.31 45760556 --- -- ---xx Track15.flac
5:11.12 54888668 --- -- ---xx Track16.flac
78:15.39 789.92 MB (totals for 16 files, 0.5838 o
verall compression ratio)

I use dthe shntool sbe batch file and:

length expanded size cdr WAVE problems filename
3:50.41 40668476 --- -- ----- Track01-fixed.wav
0:55.16 9739676 --- -- ----- Track02-fixed.wav
0:22.71 4047836 --- -- ----- Track03-fixed.wav
4:02.53 42813500 --- -- ----- Track04-fixed.wav
6:29.08 68638460 --- -- ----- Track05-fixed.wav
4:35.59 48648812 --- -- ----- Track06-fixed.wav
12:48.13 135505820 --- -- ----- Track07-fixed.wav
21:19.38 225705020 --- -- ----- Track08-fixed.wav
3:32.49 37512092 --- -- ----- Track09-fixed.wav
1:25.34 15074012 --- -- ----- Track10-fixed.wav
0:25.74 4584092 --- -- ----- Track11-fixed.wav
4:43.64 50071772 --- -- ----- Track12-fixed.wav
0:33.05 5833004 --- -- ----- Track13-fixed.wav
3:39.71 38798636 --- -- ----- Track14-fixed.wav
4:19.31 45760556 --- -- ----- Track15-fixed.wav
5:11.13 54891020 --- -- ----- Track16-fixed.wav
78:15.40 789.92 MB (totals for 16 files, 1.0000 o
verall compression ratio)

So I guess it works (but the command is for backward fix)

uhclem
2005-03-20, 09:22 PM
Can you post a Batch file for fixing SBEs? I just checked a show and all files have them. :(

Don't use a batch file for fixing SBEs. Here's why (http://www.thetradersden.org/forums/showthread.php?t=3859). Use TLH or BatchEnc.

Five
2005-03-20, 09:40 PM
Don't use a batch file for fixing SBEs. Here's why (http://www.thetradersden.org/forums/showthread.php?t=3859). Use TLH or BatchEnc.
:roflol: such a great thread!

pmonk
2005-03-20, 10:17 PM
This is getting beyond my understanding!

As I said - I download a Hendrix studio torrent over on eztree and this is what I got

length expanded size cdr WAVE problems filename
3:50.41 40668476 --- -- ---xx Track01.flac
0:55.16 9740528 -b- -- ---xx Track02.flac
0:22.71 4047836 --- -- ---xx Track03.flac
4:02.53 42813500 --- -- ---xx Track04.flac
6:29.08 68638460 --- -- ---xx Track05.flac
4:35.59 48648812 --- -- ---xx Track06.flac
12:48.13 135505416 -b- -- ---xx Track07.flac
21:19.38 225705424 -b- -- ---xx Track08.flac
3:32.49 37512092 --- -- ---xx Track09.flac
1:25.34 15074012 --- -- ---xx Track10.flac
0:25.74 4584092 --- -- ---xx Track11.flac
4:43.64 50071772 --- -- ---xx Track12.flac
0:33.05 5833004 --- -- ---xx Track13.flac
3:39.71 38798636 --- -- ---xx Track14.flac
4:19.31 45760556 --- -- ---xx Track15.flac
5:11.12 54888668 --- -- ---xx Track16.flac
78:15.39 789.92 MB (totals for 16 files, 0.5838 overall compression ratio)


When I used TLH to fix the sbe, I got this:

length expanded size cdr WAVE problems filename
3:50.41 40668476 --- -- ---xx Track01.flac
0:55.16 9739676 --- -- ---xx Track02-fixed.flac
0:22.71 4047836 --- -- ---xx Track03-fixed.flac
4:02.53 42813500 --- -- ---xx Track04-fixed.flac
6:29.08 68638460 --- -- ---xx Track05-fixed.flac
4:35.59 48648812 --- -- ---xx Track06-fixed.flac
12:48.13 135505820 --- -- ---xx Track07-fixed.flac
21:19.38 225705020 --- -- ---xx Track08-fixed.flac
3:32.49 37512092 --- -- ---xx Track09-fixed.flac
1:25.34 15074012 --- -- ---xx Track10-fixed.flac
0:25.74 4584092 --- -- ---xx Track11-fixed.flac
4:43.64 50071772 --- -- ---xx Track12-fixed.flac
0:33.05 5833004 --- -- ---xx Track13-fixed.flac
3:39.71 38798636 --- -- ---xx Track14-fixed.flac
4:19.31 45760556 --- -- ---xx Track15-fixed.flac
5:11.13 54891020 --- -- ---xx Track16-fixed.flac
78:15.40 789.92 MB (totals for 16 files, 0.5600 overall compression ratio)

All tracks went thru the process but the ending digits of the size of the fixed tracks have the same numbers.

Now when I used batchenc and just added the tracks that hd the errors, I got this:

length expanded size cdr WAVE problems filename
3:50.41 40668476 --- -- ---xx Track01.flac
0:55.16 9739676 --- -- ---xx Track02-fixed.flac
0:22.72 4050188 --- -- ---xx Track03-fixed.flac
4:02.53 42813500 --- -- ---xx Track04.flac
6:29.08 68638460 --- -- ---xx Track05.flac
4:35.59 48648812 --- -- ---xx Track06.flac
12:48.12 135503468 --- -- ---xx Track07-fixed.flac
21:19.39 225707372 --- -- ---xx Track08-fixed.flac
3:32.49 37512092 --- -- ---xx Track09.flac
1:25.34 15074012 --- -- ---xx Track10.flac
0:25.74 4584092 --- -- ---xx Track11.flac
4:43.64 50071772 --- -- ---xx Track12.flac
0:33.05 5833004 --- -- ---xx Track13.flac
3:39.71 38798636 --- -- ---xx Track14.flac
4:19.31 45760556 --- -- ---xx Track15.flac
5:11.12 54888668 --- -- ---xx Track16.flac
78:15.40 789.92 MB (totals for 16 files, 0.5771 overall compression ratio)

Track 7 and 8 now have diferent sizes???

Obviously I'm playing around but curious about the results?

uhclem
2005-03-20, 10:48 PM
Now when I used batchenc and just added the tracks that hd the errors, ...
Oops, that's your mistake. You can't fix just the tracks that have errors. You have to fix the entire set of seamless files together because shntool moves track breaks back and forth.

You can only skip tracks that don't need fixing if and ONLY if they come before the first track that has an SBE. In this case, that means you can skip track01, but that's it. Notice that when you fixed them with TLH, EVERY track except for track01 ended up with '-fixed' appended to it. That's not just there for fun, it's there to tell you that that track was changed.

pmonk
2005-03-20, 10:56 PM
Now what would happen if I burn that last set to a cd-r???

uhclem
2005-03-20, 11:02 PM
It would be a disaster because the fix you have performed has moved parts of the completely wrong tracks onto the fronts or ends of other tracks, depending on what kind of shift you used, i.e. you will find a millisecond of the end of track02 shifted to the beginning of track07 or a millisecond of the front of track07 shifted to the end of track02. I doubt that's what you wanted.

As for track08, all you've done is padded the end of it, which is pointless.

Frankly you are better off just burning it with the SBEs, than burning a fix job like that. I would consider such a 'fix' to be a complete and total fuckup.

Think of it this way: When you are fixing SBEs with shntool or TLH, you are moving the track breaks to where they should have been placed had the original Big Wave File been tracked along sector boundary lines. In order to do this, shntool has to work with the entire Big Wave File just like CDwave had to do. It can't work with only bits and pieces of the Big Wave File.

uhclem
2005-03-20, 11:19 PM
I also meant to say that the reason many of the tracks are the exact same size before and after the fix is because the same amount of data have been snipped off the front of the track as has been added to the end of it. The tracks are, nevertheless, different, as the -fixed tells you.

One thing to be aware of though. If you use the -noskip argument, shntool will append -fixed to each track regardless of whether it was actually fixed or not. But the -noskip argument is only to be used when you are converting the files from one format to another while you are fixing them.

feralicious
2005-03-21, 12:44 AM
I also meant to say that the reason many of the tracks are the exact same size before and after the fix is because the same amount of data have been snipped off the front of the track as has been added to the end of it. The tracks are, nevertheless, different, as the -fixed tells you.

One thing to be aware of though. If you use the -noskip argument, shntool will append -fixed to each track regardless of whether it was actually fixed or not. But the -noskip argument is only to be used when you are converting the files from one format to another while you are fixing them.That was a question I had... do you need to change flac to wav when you fix? Or is it okay to fix it and keep it as a flac? (Not that I've even been able to achieve that, but if it's okay and possible I'd like to.)

feralicious
2005-03-21, 12:46 AM
As for track08, all you've done is padded the end of it, which is pointless.

Frankly you are better off just burning it with the SBEs, than burning a fix job like that. I would consider such a 'fix' to be a complete and total fuckup. :roflol: :roflol: :roflol:

pmonk, go directly to Jail. Do not pass Go, do not collect $200. :lol

pmonk
2005-03-21, 07:54 AM
:roflol: :roflol: :roflol:

pmonk, go directly to Jail. Do not pass Go, do not collect $200. :lol

As I said - I was just playing around.

If you use shntool the fix would be converted to .wav.

If you use TLH - the tracks will remain in the compressed form.

uhclem
2005-03-21, 11:27 AM
I realize you were just experimenting, pmonk. But if you need it here you go:
http://img203.exs.cx/img203/1020/getoutofjailfree6dr.gif

Shntool can output the fixed files in any audio format recognized by shntool, which includes shn, flac, wav and several others. Just insert the '-o [format]' argument after the fix argument, e.g.:

shntool fix -o flac *.flac

If you run a fix like this, only the files that need fixing will end up fixed. You will recognize them by '-fixed' being appended to the name. You can then delete their corresponding unfixed versions and you will end up with a fixed set consisting of a mix of unfixed and '-fixed' files (unless all of them had to be fixed).

Use the -noskip argument if you are outputting to a format different from the input format. This way shntool will convert those files which it doesn't actually need to fix, e.g. shntool fix -noskip -o flac *.shn

feralicious
2005-03-21, 11:41 AM
As I said - I was just playing around.I know... I still love you. I just like to tease. :icon_hug:

dancin_carrot
2005-03-27, 02:08 PM
Does anyone know what level of FLAC compression is used with shntool? And is there a way to change it?

jazzbo
2005-03-27, 05:19 PM
Does anyone know what level of FLAC compression is used with shntool? And is there a way to change it?

5 (the default) and yes.

You have to use the cust format in shntool:

For example, here's a SHN file on my harddrive. (Sorry, all of my examples are in a unix shell, but the examples should be applicable to a Windows machine, just follow the instructions in the shntool documention about quoting the curly braces. But the important thing is I marked the file sizes so you can see the higher compression level working.)

/data2/bwq1977feb7$ ls -la bwq1977feb7track01.shn
-rw-r--r-- 1 kevin kevin 3437861 2004-06-27 17:40 bwq1977feb7track01.shn


Now, default FLAC compression from shntool at level 5:

/data2/bwq1977feb7$ shntool conv -o flac bwq1977feb7track01.shn
converting 'bwq1977feb7track01.shn' to 'bwq1977feb7track01.flac' ... done.

/data2/bwq1977feb7$ ls -la bwq1977feb7track01.flac
-rw-r--r-- 1 kevin kevin 3354437 2005-03-27 17:02 bwq1977feb7track01.flac


Now, force level 8 with the cust format:

/data2/bwq1977feb7$ shntool conv -o cust ext=flac8 { flac - -8 -o %f } -d . *track01.shn
converting 'bwq1977feb7track01.shn' to './bwq1977feb7track01.custom' ... done.

/data2/bwq1977feb7$ ls -la bwq1977feb7track01.flac8
-rw-r--r-- 1 kevin kevin 3345563 2005-03-27 17:05 bwq1977feb7track01.flac8


The cust command here is forcing the output extension to be flac8 (just for comparison purposes while I was running the test) and passing STDIN ("-") to be compressed at level 8. I couldn't get it to work without explicitly stating I wanted output in the present path with the -d switch.

Once you get the cust format working on your setup, you can use it for output with any of shntool's modules. You can also use cust to incorporate new compression formats into shntool without the support being waiting for support to be added to shntool.

pmonk
2005-03-27, 09:11 PM
I created a batch file to create md5 signatures - but I would like to it to be able to automatically name the .md5 the name of the folder that was dragged into the batch file. Is that possible???

dancin_carrot
2005-03-27, 09:21 PM
Pretty cool jazzbo, thanks! I'll try to get that working if I have some time, but I've just discovered that foobar2000 can do conversion to flac level 8 from flac files encoded at an unknown level.

My next question is, is there a way to test flac files to see what level they are encoded to?

feralicious
2005-03-28, 12:16 AM
I created a batch file to create md5 signatures - but I would like to it to be able to automatically name the .md5 the name of the folder that was dragged into the batch file. Is that possible???The following works to make an SBE check file named with the folder name, perhaps you can incorporate it and modify it for md5?

shntool len with txt file added to folder:

@<hidden> off
%~d1 & cd %*
for %%T in (shn flac wav ape) do if exist *.%%T shntool len -u mb *.%%T >> "%~n1-shntool.txt"

pmonk
2005-03-28, 08:45 AM
That did the trick - thanks :)

uhclem
2005-04-01, 10:35 AM
Does anyone know what level of FLAC compression is used with shntool? And is there a way to change it?
The answer is essentially the same for Windows users as for *nix users such as Jazzbo, except you have to put single quotes around the curly brackets, e.g.:

'{' flac - -8 -o %f '}'

Make sure there is a space between each ' and the code before or after it inside the curly brackets.

When I want to perform a fix and compress to a non-default level of flac compression, I make a custom batch file and I create the custom file type as a variable. This makes the code a little easier to read, and I can easily cut and paste from one batch file into another for other fixes. I create a variable called 'typ' (for file type) at the beginning of the batch file like this:

set typ=cust ext=flac '{' flac -o %%f -V -8 - '}'

I then use 'typ' as my shntool file format with the -o argument, like this:

shntool fix -s r -o %typ% [input files]

You can use the 'typ' variable with any shntool command. For a straight conversion, for instance, set the typ variable as above, then use a command such as the following:

shntool conv -o %typ% *.shn

dancin_carrot
2005-04-01, 05:33 PM
Very cool uhclem, thanks a lot!

roann
2005-04-19, 06:58 PM
... When I want to perform a fix and compress to a non-default level of flac compression, I make a custom batch file and I create the custom file type as a variable. This makes the code a little easier to read, and I can easily cut and paste from one batch file into another for other fixes. I create a variable called 'typ' (for file type) at the beginning of the batch file like this:

set typ=cust ext=flac '{' flac -o %%f -V -8 - '}'

I then use 'typ' as my shntool file format with the -o argument, like this:

shntool fix -s r -o %typ% [input files]

...Thnx for this, uhclem. I tried the same on ape files but failed. One of the lines I tested was
shntool fix -s b -o cust ext=ape '{' mac %f -c4000 '}' "Test 01.ape" "Test 02.ape" "Test 03.ape"
Only some useless warnings / error messages showed up ("make sure that there is enough disk space + the specified output directory exists" and stuff like that). Can you give me a helping hand pls?

uhclem
2005-04-19, 09:16 PM
You didn't specify an input file inside the curly brackets. When working with a custom format the input should always be 'standard in' which is signified simply by a dash, '-'

So try this inside the curlys and let me know if it works:

mac - %f -c4000

roann
2005-04-20, 03:50 AM
You didn't specify an input file inside the curly brackets. When working with a custom format the input should always be 'standard in' which is signified simply by a dash, '-'

So try this inside the curlys and let me know if it works:

mac - %f -c4000Fantastico, this works perfectly. Thanks very much!

feralicious
2005-07-13, 04:27 AM
bumpity bump