IPB

Welcome Guest ( Log In | Register )

Making a list of all WV files with a deviant compression, using wvunpack?
Fandango
post Dec 17 2009, 17:16
Post #1





Group: Members
Posts: 1540
Joined: 13-August 03
Member No.: 8353



I'm not very good with DOS batch scripts. The lack of piping text output and the lack of any native text stream processor makes it very hard to achieve what I'm planning to do:

foobar2000 does not support showing the exact encoding profile in Wavpack files. All it shows will be "Wavpack fast", "Wavpack normal"(?) and "Wavpack high". But I want to transcode all Wavpack files to a certain compression level and the problem is that some of my files have already been compressed with those settings but many haven't.

The only tool I know that can show me the actual compression settings is wvunpack.exe. Now if I were using a Linux machine, it be a piece of cake for me to write a shell script that gives me a list of all WV files that do not match my preferred compression. (I need to get a list although I could transcode them right away using the script, but since I have a quad core I'd rather have a multi-threading capable launcher do that, like foobar2000).

So how would I get it done in Windows? I guess it would be very easy with Powershell, although lerning how to use the PS isn't that easy... laugh.gif
Go to the top of the page
+Quote Post
 
Start new topic
Replies
_mē_
post Dec 17 2009, 17:35
Post #2





Group: Members
Posts: 231
Joined: 6-April 09
Member No.: 68706



QUOTE (Fandango @ Dec 17 2009, 17:16) *
I'm not very good with DOS batch scripts. The lack of piping text output and the lack of any native text stream processor makes it very hard to achieve what I'm planning to do:

foobar2000 does not support showing the exact encoding profile in Wavpack files. All it shows will be "Wavpack fast", "Wavpack normal"(?) and "Wavpack high". But I want to transcode all Wavpack files to a certain compression level and the problem is that some of my files have already been compressed with those settings but many haven't.

The only tool I know that can show me the actual compression settings is wvunpack.exe. Now if I were using a Linux machine, it be a piece of cake for me to write a shell script that gives me a list of all WV files that do not match my preferred compression. (I need to get a list although I could transcode them right away using the script, but since I have a quad core I'd rather have a multi-threading capable launcher do that, like foobar2000).

So how would I get it done in Windows? I guess it would be very easy with Powershell, although lerning how to use the PS isn't that easy... laugh.gif

A simplified version of my script:
CODE
@echo off

::::::::::::::::::::
:: DEPENDENCIES:
:: - flac
:: - mac
:: - wavpack
:: - wvunpack


::::::::::::::::::::
:: SETTINGS

set PACKER.CMD=wavpack -hhx6 %%in%% %%out%%
set PACKER.FILE_EXTENSION=wv

::::::::::::::::::::
:: START


:get_temp_file_name
set TMP_FILE=%TMP%\c%RANDOM%.tmp
IF EXIST "%TMP_FILE%" goto get_temp_file_name

for /r %%a in (*.*) DO echo "%%a">>"%TMP_FILE%"
for /f "delims=" %%a in (%TMP_FILE%) DO call :convert %%a
del "%TMP_FILE%"

:convert
::there's an issue with files containing '&' character. That's why I add and remove the quotes
set fst="%~nx1"
call :DeQuote fst

set name="%~n1"
call :DeQuote name

echo "%fst%"

set Delete=1

:: convert to wav
if /i [%~x1] == [.wav] (
     set Delete=0
     goto compress
)
if /i [%~x1] == [.ape] (
     mac "%fst%" "%name%.wav" -d
     if [.%PACKER.FILE_EXTENSION%] == [%~x1] rename "%~dpnx1" "_%~nx1"
     goto compress
)
if /i [%~x1] == [.flac] (
     flac -d "%fst%" "%name%.wav"
     if [.%PACKER.FILE_EXTENSION%] == [%~x1] rename "%~dpnx1" "_%~nx1"
     goto compress
)
if /i [%~x1] == [.shn] (
     shorten -x "%fst%" "%name%.wav"
     if [.%PACKER.FILE_EXTENSION%] == [%~x1] rename "%~dpnx1" "_%~nx1"
     goto compress
)
if /i [%~x1] == [.wv] (
::--------------- ADD CHECKING FOR SETTINGS AFTER THIS LINE ---------------------
     wvunpack "%fst%" "%name%.wav"
     if [.%PACKER.FILE_EXTENSION%] == [%~x1] rename "%~dpnx1" "_%~nx1"
     goto compress
)
::not a convertable file
goto :eof

:: compress one file
:compress

set in="%name%.wav"
set out="%~dpn1.%PACKER.FILE_EXTENSION%"
cmd /c %PACKER.CMD%

::cleanup
if %Delete% == 1 (
     del "%name%.wav"
)
goto :EOF

:: DeQuote
:DeQuote

SET DeQuote.Variable=%1
CALL Set DeQuote.Contents=%%%DeQuote.Variable%%%
CALL Set DeQuote.Contents=%DeQuote.Contents:&=__AND__%
Echo.%DeQuote.Contents%|FindStr/brv ""^">NUL:&&Goto :EOF
Echo.%DeQuote.Contents%|FindStr/erv ""^">NUL:&&Goto :EOF
  
Set DeQuote.Contents=####%DeQuote.Contents%####
Set DeQuote.Contents=%DeQuote.Contents:####"=%
Set DeQuote.Contents=%DeQuote.Contents:"####=%
Set %DeQuote.Variable%=%DeQuote.Contents:__AND__=^&%
  
Set DeQuote.Variable=
Set DeQuote.Contents=
Goto :EOF

1. You need to enter checking for wavpack version in the marked place. I suggest parsing wvunpack output with grep.
I don't knot what did you mean with lack of piping, but wvunpack parameters | grep grep_parameters should work.
2. Unicode file names cause problems
3. It's not thoroughly debugged
4. Just BTW, if you're into space reduction, recently I saved .5 gig just by recompressing artwork.

This post has been edited by _mē_: Dec 17 2009, 17:56
Go to the top of the page
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 25th May 2013 - 04:34