Created
August 9, 2016 05:14
-
-
Save shortland/8381445517df5b15e6adbafcf00d9537 to your computer and use it in GitHub Desktop.
Perl; Add prefix to all files in a directory
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
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| my $dir = 'rename_these/'; | |
| opendir(DIR, $dir) or die $!; | |
| while (my $file = readdir(DIR)) | |
| { | |
| # ignores files beginning with a period | |
| next if ($file =~ m/^\./); | |
| `mv "$dir$file" $dir"removed_8_9_16_$file"`; | |
| } | |
| closedir(DIR); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment