Skip to content

Instantly share code, notes, and snippets.

@shortland
Created August 9, 2016 05:14
Show Gist options
  • Select an option

  • Save shortland/8381445517df5b15e6adbafcf00d9537 to your computer and use it in GitHub Desktop.

Select an option

Save shortland/8381445517df5b15e6adbafcf00d9537 to your computer and use it in GitHub Desktop.
Perl; Add prefix to all files in a directory
#!/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