Skip to content

Instantly share code, notes, and snippets.

@YourFriendCaspian
Forked from mgcon/replaceSpaces.pl
Created January 31, 2019 09:26
Show Gist options
  • Save YourFriendCaspian/cc5df20b67a073111569567134f7b7b8 to your computer and use it in GitHub Desktop.
Save YourFriendCaspian/cc5df20b67a073111569567134f7b7b8 to your computer and use it in GitHub Desktop.
replace spaces in file names with underscores
#!/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