Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
$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