Created
June 3, 2021 23:31
-
-
Save jkonrath/fb471f4d15947555af254c877ca04d53 to your computer and use it in GitHub Desktop.
Windows CMD underscores to dashes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem Go through every file in a directory and replace _ with - in each filename. | |
rem I'm sure I pasted this from somewhere, no idea. | |
rem I wouldn't have to do this if people stopped using underscores in filenames. | |
rem It's bad SEO, and it's that much more typing. Just stop it. | |
Setlocal enabledelayedexpansion | |
rem You could change these two to replace any string with another. | |
Set "Pattern=_" | |
Set "Replace=-" | |
For %%a in (*.*) Do ( | |
Set "File=%%~a" | |
Ren "%%a" "!File:%Pattern%=%Replace%!" | |
) | |
Pause&Exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment