A collection of PowerShell scripts for audio file management and playlist generation.
A PowerShell script that copies a random subset of audio files from a source library with advanced features like FLAC to MP3 conversion, artist limits, and flexible renaming schemes.
A PowerShell script that searches for audio files based on a CSV file containing song names and artists, creating playlists from found matches using fuzzy string matching. Always creates a full paths file for use with CopyFromList.ps1.
A PowerShell script that copies audio files from a list of full file paths while preserving folder structure. Supports FLAC to MP3 conversion and multiple file renaming schemes based on audio metadata.
- Random Selection: Pick random audio files from your music library
- Two Modes:
- Total Mode: Select a specific total number of files across entire library
- Per-Folder Mode: Select a specific number of files from each folder
- Artist Limits: Limit maximum files per artist to ensure variety
- FLAC to MP3 Conversion: Convert FLAC files to MP3 with metadata and cover art preservation
- Flexible Renaming: Multiple file naming schemes
- Dry Run: Preview actions without actually copying files
- Interactive Mode: GUI-like prompts when run without parameters
- Preserves Structure: Maintains original folder hierarchy in output
- CSV Input: Reads song and artist names from CSV file
- Fuzzy Matching: Intelligent string matching for both artist names and song titles
- Configurable Thresholds: Adjustable similarity percentages for matching
- Multiple Formats: Supports M3U, PLS, and WPL playlist formats
- Path Type Control: Generate playlists with relative or absolute file paths
- Full Paths File: Always creates a companion file with full file paths for use with CopyFromList.ps1
- Interactive Mode: GUI-like prompts when run without parameters
- Dry Run: Preview matches without creating playlist
- Metadata Reading: Uses ffprobe for accurate metadata extraction
- Full Path Input: Reads file paths from text files (typically generated by PlaylistGen.ps1)
- Structure Preservation: Maintains artist/album folder hierarchy starting from artist folder
- FLAC to MP3 Conversion: Convert FLAC files to MP3 with metadata and cover art preservation
- Metadata-Based Renaming: Multiple file naming schemes using extracted audio metadata
- Interactive Mode: GUI-like prompts when run without parameters
- Dry Run: Preview actions without actually copying files
- Progress Reporting: Shows detailed progress and success rates
- FLAC
- MP3
- WAV
- AAC
- OGG
- M4A
- WMA
- PowerShell 5.0 or later
- ffmpeg and ffprobe (for FLAC conversion and metadata reading)
- Download from: https://ffmpeg.org/download.html
- Must be in system PATH
The scripts are designed to work together in a complete audio management workflow:
-
PlaylistGen.ps1: Search your music library using a CSV file and create playlists
- Generates standard playlists (M3U/PLS/WPL) for media players
- Creates full paths file (
PlaylistName-FullPaths.txt
) for use with CopyFromList.ps1
-
CopyFromList.ps1: Copy and organize the found files
- Uses the full paths file from PlaylistGen.ps1
- Preserves folder structure (Artist/Album hierarchy)
- Optionally converts FLAC to MP3
- Optionally renames files using metadata
# Find songs from CSV and create playlist
.\PlaylistGen.ps1 -Src "D:\Music" -CsvSrc "wishlist.csv" -PlaylistName "MyWishlist"
# Copy found songs with conversion and renaming
.\CopyFromList.ps1 -Src "MyWishlist-FullPaths.txt" -Dest "E:\Portable" -ConvertToMp3 -RenameScheme "TrackArtistSong"
This workflow allows you to:
- Maintain your original music library untouched
- Create organized, converted copies for different devices
- Use CSV files to batch-process song collections
- Preserve folder structure while applying consistent naming
The CSV file should contain songs in the following format:
Song Title,Artist Name
Always Be (feat. Kaya Thomas-Dyke),Alfa Mist
In The Stars,Melody's Echo Chamber
Dålig teve,Dina Ögon
ps2exe -inputFile RandomSongs.ps1 -outputFile RandomSongs.exe
ps2exe -inputFile PlaylistGen.ps1 -outputFile PlaylistGen.exe
ps2exe -inputFile CopyFromList.ps1 -outputFile CopyFromList.exe
Simply run without parameters for guided setup:
RandomSongs.ps1:
.\RandomSongs.ps1
PlaylistGen.ps1:
.\PlaylistGen.ps1
CopyFromList.ps1:
.\CopyFromList.ps1
Basic usage - 100 random songs:
.\RandomSongs.ps1 -Src "D:\Music" -Dest "E:\Output" -Total 100
With artist limits and FLAC conversion:
.\RandomSongs.ps1 -Src "D:\Music" -Dest "E:\Output" -Total 500 -MaxPerArtist 3 -ConvertToMp3
Per-folder mode with custom naming:
.\RandomSongs.ps1 -Src "D:\Music" -Dest "E:\Output" -Count 5 -RenameScheme "artist-title"
Dry run to preview actions:
.\RandomSongs.ps1 -Src "D:\Music" -Total 100 -DryRun
Basic usage - Create playlist from CSV:
.\PlaylistGen.ps1 -Src "D:\Music" -CsvSrc "songs.csv" -Dest "E:\Playlists"
With custom thresholds:
.\PlaylistGen.ps1 -Src "D:\Music" -CsvSrc "songs.csv" -ArtistThreshold 90 -SongThreshold 60
Different playlist format:
.\PlaylistGen.ps1 -Src "D:\Music" -PlaylistFormat "PLS" -PlaylistName "MyPlaylist"
Dry run to preview matches:
.\PlaylistGen.ps1 -Src "D:\Music" -CsvSrc "songs.csv" -DryRun
Basic usage - Copy files from full paths list:
.\CopyFromList.ps1 -Src "playlist-FullPaths.txt" -Dest "E:\Output"
With FLAC conversion:
.\CopyFromList.ps1 -Src "playlist-FullPaths.txt" -Dest "E:\Output" -ConvertToMp3
With metadata-based renaming:
.\CopyFromList.ps1 -Src "playlist-FullPaths.txt" -Dest "E:\Output" -RenameScheme "ArtistSong"
Combined: Convert and rename with track numbers:
.\CopyFromList.ps1 -Src "playlist-FullPaths.txt" -Dest "E:\Output" -ConvertToMp3 -RenameScheme "TrackArtistSong"
Dry run to preview actions:
.\CopyFromList.ps1 -Src "playlist-FullPaths.txt" -DryRun
Parameter | Type | Description | Default |
---|---|---|---|
-Src |
String | Source music library path | Current directory |
-Dest |
String | Destination output path | "Output" folder |
-Count |
Integer | Files per folder (per-folder mode) | 3 |
-Total |
Integer | Total files to select (total mode) | Not set |
-ConvertToMp3 |
Switch | Convert FLAC files to MP3 | False |
-MaxPerArtist |
Integer | Maximum files per artist | No limit |
-RenameScheme |
String | File naming scheme | "number-title" |
-DryRun |
Switch | Preview only, don't copy files | False |
Parameter | Type | Description | Default |
---|---|---|---|
-Src |
String | Source music library path | Current directory |
-Dest |
String | Destination playlist path | Current directory |
-CsvSrc |
String | CSV file with songs to find | "addToPlaylist.csv" |
-ArtistThreshold |
Integer | Artist name matching percentage | 80 |
-SongThreshold |
Integer | Song title matching percentage | 50 |
-PlaylistFormat |
String | Playlist format (M3U/PLS/WPL) | "M3U" |
-PlaylistName |
String | Name of the generated playlist | "GeneratedPlaylist" |
-PathType |
String | Path type in playlist (Relative/Absolute) | "Relative" |
-DryRun |
Switch | Preview only, don't create playlist | False |
Parameter | Type | Description | Default |
---|---|---|---|
-Src |
String | Full paths file to read from | Required |
-Dest |
String | Destination output path | "Output" folder |
-ConvertToMp3 |
Switch | Convert FLAC files to MP3 | False |
-RenameScheme |
String | File naming scheme | "Original" |
-DryRun |
Switch | Preview only, don't copy files | False |
number-title
(default):01 Song Title.mp3
number-artist-title
:01 Artist Name - Song Title.mp3
artist-title
:Artist Name - Song Title.mp3
Original
(default): Keeps original filename (e.g.,01 Enter Sandman.flac
)ArtistSong
:Artist - Song.ext
(e.g.,Apocalyptica - Enter Sandman.flac
)SongArtist
:Song - Artist.ext
(e.g.,Enter Sandman - Apocalyptica.flac
)TrackArtistSong
:01 Artist - Song.ext
(e.g.,01 Apocalyptica - Enter Sandman.flac
)
- M3U (default): Standard playlist format, widely supported
- PLS: Winamp/Shoutcast playlist format
- WPL: Windows Media Player playlist format
- Scans entire source library for audio files
- Randomly selects specified number of files
- Respects per-artist limits if specified
- Copies to destination maintaining folder structure
- Processes each subfolder individually
- Selects specified number of random files from each folder
- Copies non-audio files (cover art, etc.) from folders with selected audio
- Maintains original folder hierarchy
When -ConvertToMp3
is enabled:
- Converts FLAC files to high-quality MP3 (VBR ~192kbps)
- Preserves all metadata tags
- Embeds cover art from FLAC file
- Resizes cover art to 300x300px for efficiency
- Reads CSV file with song names and artist names
- Scans source library for all audio files
- Extracts metadata (artist, title) from each file using ffprobe
- Uses fuzzy string matching to find best matches
- Creates playlist with found matches
- Artist Matching: Default 80% similarity threshold
- Song Matching: Default 50% similarity threshold
- Uses Levenshtein distance algorithm for intelligent matching
- Handles variations in spelling, punctuation, and formatting
- Files must meet both artist AND song thresholds to be included
- Best match (highest combined similarity) is selected when multiple matches exist
- Fallback to folder/filename if metadata extraction fails
- Reads full file paths from input text file (one path per line)
- Extracts artist folder structure from each path (preserves Artist/Album hierarchy)
- Optionally extracts metadata for renaming (artist, title, track number)
- Copies files while preserving folder structure starting from artist folder
- Optionally converts FLAC files to MP3 with metadata preservation
When using rename schemes other than "Original":
- Uses ffprobe to extract artist, title, and track number from audio files
- Handles different metadata tag variations (ARTIST/artist, TITLE/title, etc.)
- Automatically pads track numbers to 2 digits (01, 02, etc.)
- Sanitizes filenames while preserving UTF-8 characters
- Falls back to original filename if metadata extraction fails
When -ConvertToMp3
is enabled:
- Converts FLAC files to high-quality MP3 (VBR ~192kbps)
- Preserves all metadata tags
- Embeds cover art from FLAC file
- Resizes cover art to 300x300px for efficiency
- Can be combined with any rename scheme
The script preserves the original folder structure:
Source:
D:\Music\
├── Artist A\Album 1\01 Song.flac
└── Artist B\Album 2\02 Track.mp3
Output:
E:\Output\
├── Artist A\Album 1\01 Song.mp3
└── Artist B\Album 2\02 Track.mp3
Creates playlist files referencing original audio file locations:
Generated playlist: MyPlaylist.m3u
Content:
#EXTM3U
#EXTINF:-1,Alfa Mist - Always Be (feat. Kaya Thomas-Dyke)
D:\Music\Alfa Mist\Bring Backs\01 Always Be.flac
Full paths file: MyPlaylist-FullPaths.txt
Content:
D:\Music\Alfa Mist\Bring Backs\01 Always Be.flac
D:\Music\Melody's Echo Chamber\Bon Voyage\02 In The Stars.mp3
Preserves artist/album folder structure from original paths:
Input file: playlist-FullPaths.txt
Content:
D:\Music\Apocalyptica\Plays Metallica by Four Cellos\01 Enter Sandman.flac
Output structure:
E:\Output\
└── Apocalyptica\
└── Plays Metallica by Four Cellos\
└── 01 Apocalyptica - Enter Sandman.mp3 (with renaming + conversion)
- Use
-MaxPerArtist
for faster processing with large libraries - The script uses directory names for artist detection (faster than metadata parsing)
- FLAC conversion is CPU-intensive; consider smaller batches for older systems
- Lower thresholds increase processing time but find more matches
- Ensure ffprobe is in PATH for accurate metadata extraction
- Large music libraries may take longer to scan initially
- Metadata extraction for renaming requires ffprobe (can be skipped with "Original" scheme)
- FLAC conversion is CPU-intensive; consider processing in smaller batches
- Use dry run mode to verify folder structure and renaming before actual copying
- The script processes files sequentially for better error handling and progress tracking
- Skips inaccessible files gracefully
- Handles long file paths by truncating names
- Validates all parameters before processing
- Creates destination folders as needed
Create a 1000-song playlist with max 2 songs per artist:
.\RandomSongs.ps1 -Total 1000 -MaxPerArtist 2 -ConvertToMp3 -RenameScheme "artist-title"
Sample 5 songs from each album folder:
.\RandomSongs.ps1 -Count 5 -RenameScheme "number-artist-title"
Quick preview of what would be selected:
.\RandomSongs.ps1 -Total 50 -MaxPerArtist 1 -DryRun
Create playlist from CSV with strict matching:
.\PlaylistGen.ps1 -Src "D:\Music" -CsvSrc "wishlist.csv" -ArtistThreshold 95 -SongThreshold 80
Generate PLS playlist with relaxed matching:
.\PlaylistGen.ps1 -CsvSrc "songs.csv" -PlaylistFormat "PLS" -ArtistThreshold 70 -SongThreshold 40
Preview matches without creating playlist:
.\PlaylistGen.ps1 -CsvSrc "addToPlaylist.csv" -DryRun
Complete workflow from CSV to organized music files:
# Step 1: Generate playlist and full paths file
.\PlaylistGen.ps1 -Src "D:\Music" -CsvSrc "songs.csv" -PlaylistName "MyCollection"
# Step 2: Copy files with conversion and renaming
.\CopyFromList.ps1 -Src "MyCollection-FullPaths.txt" -Dest "E:\OrganizedMusic" -ConvertToMp3 -RenameScheme "TrackArtistSong"
Copy files with original names (fastest):
.\CopyFromList.ps1 -Src "playlist-FullPaths.txt" -Dest "E:\Backup"
Convert FLAC to MP3 with artist-song naming:
.\CopyFromList.ps1 -Src "flac-files.txt" -Dest "E:\MP3Collection" -ConvertToMp3 -RenameScheme "ArtistSong"
Preview what files will be copied and how they'll be renamed:
.\CopyFromList.ps1 -Src "playlist-FullPaths.txt" -RenameScheme "SongArtist" -DryRun
These scripts are provided as-is for personal use. Ensure you have rights to copy and convert your audio files.