• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filename format
#3
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

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
        }
  }
Reply


Messages In This Thread
Filename format - by brunocostapontes - 01-05-2023, 04:23 AM
RE: Filename format - by Zubersoft - 01-05-2023, 06:07 AM
RE: Filename format - by Dirk - 09-12-2023, 10:54 PM



Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2024 MyBB Group.