Created
August 17, 2015 02:18
-
-
Save mgcon/9d6300dd55817f2a5283 to your computer and use it in GitHub Desktop.
replace spaces in file names with underscores
This file contains 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
#!/usr/bin/perl | |
# replace spaces in all filenames with underscores | |
$dir = "."; | |
opendir(DIR, $dir) || die "Can't open $dir\n"; | |
for (readdir(DIR)) { | |
next if $_ eq '.'; | |
next if $_ eq '..'; | |
next if $_ eq 'lost+found'; | |
$newfile = $_; | |
$newfile =~ s/ /_/g; | |
rename $_, $newfile; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment