09-12-2023, 10:54 PM
Hi everyone
I also have most PDF named as ( Artist - Title .pdf )
Until this feature is implemented, I created a simple powershell script that when run in a directory
- Get all PDF files containing " - " ([SPACE][HYPHEN][SPACE] ( expected Artist - Title .pdf )
- Create Export folder
- Create One folder per artist
- Copy the PDFs to the folder with the first part removed from the Filename
I also have most PDF named as ( Artist - Title .pdf )
Until this feature is implemented, I created a simple powershell script that when run in a directory
- Get all PDF files containing " - " ([SPACE][HYPHEN][SPACE] ( expected Artist - Title .pdf )
- Create Export folder
- Create One folder per artist
- Copy the PDFs to the folder with the first part removed from the Filename
Code:
<#
PowerShell script for CreateMobileSheets Appp
Creates an Export directory in which it will copy all the PDF Files per Artist.
Source PDF Files are expected in format "Artist - Title.pdf"
CreateMobileSheets allows batch import , but only based on folder structure , not based on Filename
#>
$export_dir = 'Export'
Get-ChildItem *-*.pdf -File | # Get All PDF Files with a hyphen
Group-Object { $_.Name -replace ' -.*' } | # Group by part before first -
ForEach-Object {
# Create directory for each group
$dir = New-Item -Type Directory -Path $export_dir -Name $_.Name -Force
# Copy each File in the group
$_.Group | ForEach-Object {
$newName = $_.Name -replace '^.*- ' # remove the "Artist - " From Filenamme
$dest = Join-Path $dir $newName
Copy-Item $_ -Destination $dest
}
}