From 4dfbef6470988640cf3024f76e1c925ee76a6ff5 Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Tue, 21 Nov 2023 05:33:03 -0400 Subject: [PATCH] Todo --- hq2cd-ps1/TODO.txt | 4 ++++ hq2cd-ps1/convert-from-file.ps1 | 32 ++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 10 deletions(-) create mode 100644 hq2cd-ps1/TODO.txt diff --git a/hq2cd-ps1/TODO.txt b/hq2cd-ps1/TODO.txt new file mode 100644 index 0000000..4852b3b --- /dev/null +++ b/hq2cd-ps1/TODO.txt @@ -0,0 +1,4 @@ +Need to normalize file names on server, no stupid "’" and "'" shenanigans +https://apps.timwhitlock.info/unicode/inspect?s=%E2%80%99%27 + +either that or get child item to not print out something different than what is actually there \ No newline at end of file diff --git a/hq2cd-ps1/convert-from-file.ps1 b/hq2cd-ps1/convert-from-file.ps1 index 06a5ae3..bb9c65d 100644 --- a/hq2cd-ps1/convert-from-file.ps1 +++ b/hq2cd-ps1/convert-from-file.ps1 @@ -1,9 +1,10 @@ +# Delete output folder if it exists +if (Test-Path -Path "Output") { + Remove-Item -Path "Output" -Recurse -Force +} + # Read each line in the file $filePaths = Get-Content -Path $args[0] -$files = @() -foreach ($filePath in $filePaths) { - $files += Get-Item -Path "$($filePath)" -Force -} # Save to output folder "Output" $destination = "Output" @@ -19,20 +20,31 @@ foreach ($file in $files) { } #> -$prefix = "Z:\Music-HQ\" -$files | ForEach-Object -Parallel { - $oldLocation = $_.FullName +$filePaths | ForEach-Object -Parallel { + # Stupid apostrophe in the file name + # Intentional, as this is how Picard names files with apostrophes + $path = $_.Replace("'", "’") + + $file = Get-Item -LiteralPath $path + + $destination = "Output" + $prefix = "Z:\Music-HQ\" + + + + $oldLocation = $file.FullName # Remove the prefix $newLocation = $oldLocation.Substring($prefix.Length) # Remove the name of the file for folder creation - $newLocation = $newLocation.Substring(0, $newLocation.IndexOf($_.Name)) + $newLocation = $newLocation.Substring(0, $newLocation.IndexOf($file.Name)) # Create the folder if it doesn't exist if (-not (Test-Path -Path $destination\$newLocation)) { New-Item -Path $destination\$newLocation -ItemType Directory } + $destinationPath = $destination + "\" + $newLocation + $file.Name - $destinationPath = $destination + "\" + $newLocation + $_.Name Write-Host $destinationPath - # ffmpeg -i $_.FullName -c:a flac -sample_fmt s16 -ar 44100 $destinationPath + + ffmpeg -i $_.FullName -c:a flac -sample_fmt s16 -ar 44100 $destinationPath } \ No newline at end of file