Skip to content

Instantly share code, notes, and snippets.

@kmwalsh
Created December 15, 2024 11:44
Show Gist options
  • Save kmwalsh/5eea5458f9f7ea95a7194ca87513b296 to your computer and use it in GitHub Desktop.
Save kmwalsh/5eea5458f9f7ea95a7194ca87513b296 to your computer and use it in GitHub Desktop.
## powershell - remove everything in a filename up to the first dash
## useful when emoji are named 392394-something-something.png
foreach ($file in (get-childitem *.png).name) {
Rename-Item $file ($file -replace '^[^-]*-\s*')
}
## powershell - transform underscores to dashes
Get-ChildItem *.png | Rename-Item -NewName { $_.Name -replace '_','-' }
## CMD - prefix all files in a folder with a given prefix
for /f "Tokens=*" %f in ('dir /l/b/a-d') do (rename "%f" "PREFIX_HERE-%f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment