IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
FLAC To WavPack PowerShell script
Agent69
post Jan 18 2010, 04:13
Post #1





Group: Members
Posts: 192
Joined: 4-January 02
From: USA
Member No.: 912



This is my FLAC To WavPack PowerShell script. It is probably not very good, but I thought I would share it with the community anyway. A couple of things:

1. PowerShell seems to have issues with piping the output of flac.exe directly to wavpack.exe, so I use a temporary .wav file to get things done. This is something that I real programmer probably could have got around.

2. Windows, by default, does not allow the execution of PowerShell scripts, so if you decide to use or create one of your own, you will have to alter a security setting.

3. This script assumes FLAC and WavPack are in your execution path.

So anyway, here it is!


CODE

# Flac2WavPack by Agent69 (2010)
# This script assumes that FLAC and WavPack are in your command path.
#
#
# THIS SCRIPT ACCEPTS ONE COMMAND LINE ARGUMENT. CHECK TO MAKE SURE:
if ($args.count -ne 1)
{
Write-Host "This script excepts only a single arguement. If you wish to convert all"
Write-Host "the .flac files in the current directory, you can use the * character."
Write-Host
exit;
}

# GET ONLY THE FLAC FILES (TO PREVENT TRYING TO PROCESS NON-FLAC FILES) AND GET THE PROCESS LOOP STARTED:
$tempt=get-childitem -Include *.flac $args[0]
foreach ($file in $tempt)
{

# CAPTURE THE METADATA INFO FROM THE SOURCE FLAC FILE USING FLAC'S METAFLAC COMMAND:
$DAT = metaflac --show-tag=DATE $file
$TOT = metaflac --show-tag=TOTALTRACKS $file
$TRK = metaflac --show-tag=TRACKNUMBER $file
$ALB = metaflac --show-tag=ALBUM $file
$ART = metaflac --show-tag=ARTIST $file
$TIT = metaflac --show-tag=TITLE $file

# REMOVE THE UNWANTED CHARACTERS FROM THE BEGINNING OF METAFLAC'S STRING OUTPUT:
$DAT = $DAT.Substring(5)
$TOT = $TOT.Substring(12)
$TRK = $TRK.Substring(12)
$ALB = $ALB.Substring(6)
$ART = $ART.Substring(7)
$TIT = $TIT.Substring(6)

# CREATE VARIABLES FOR THE WORKING (OUTPUT) DIRECTORY AND THE TEMP WAV FILE:
$workdir = "Z:\Repository\Audio--Working"
$temptwav = $file.BaseName+".wav"

# OUTPUT NOTICE TO THE USER:
Write-Host Converting $file to Wavpack format ...

# DECODE .FLAC FILE TO A TEMP .WAV FILE AND REENCODE TO WAVPACK:
flac -d $file -o $workdir\$temptwav
wavpack -d -m -w "ALBUM=$ALB" -w "ARTIST=$ART" -w "DATE=$DAT" -w "TITLE=$TIT" -w "TOTALTRACKS=$TOT" -w "TRACKNUMBER=$TRK" $workdir\$temptwav $workdir
}

# OUT OF THE PROCESSING LOOP. LET THEM KNOW YOU'RE DONE:
Write-Host Conversion complete!
Write-Host
Go to the top of the page
+Quote Post

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: 22nd December 2014 - 13:04