Created
April 6, 2017 11:54
-
-
Save valpackett/f1906faa6ad8eb122ee47c23fff24ff4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$itDir = "D:\iTunes Media\Music\" | |
$dstDir = "D:\Music\" | |
$ffmpeg = "C:\Users\greg\Downloads\ffmpeg-20170321-db7a05d-win64-shared\bin\ffmpeg.exe" | |
$itLib = Get-ChildItem -Include @("*.m4a", "*.aac", "*.mp3", "*.flac") -LiteralPath $itDir -Recurse | |
foreach ($path in $itLib) { | |
if ((Get-Item -LiteralPath $path.FullName).Attributes -band [IO.FileAttributes]::Directory) { | |
Write-Output "Directory $($path.FullName)" | |
} else { | |
$destPath = ([io.path]::ChangeExtension($path.FullName, "opus")).Replace($itDir, $dstDir) | |
$destDirPath = (($destPath -split '\\')[0..(($destPath -split '\\').count -2)] -join '\') | |
Write-Output "File $($path.FullName) → $destPath" | |
if (-not (Test-Path -LiteralPath $destDirPath)) { | |
md -Force $destDirPath | |
} | |
if (-not (Test-Path -LiteralPath $destPath)) { | |
& $ffmpeg -i $path.FullName -c:a libopus -b:a 112k -metadata account_id="" -metadata compatible_brands="" -metadata rating="" -metadata comment="" -metadata creation_time="" $destPath | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment