Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $!/usr/bin/perl
- $dir = "/path/to/files/with/trailing/slash/";
- opendir($dh, $dir);
- while (readdir $dh) {
- $new_filename = "yourname.txt";
- if (-e "$dir$new_filename") {
- print "Error: file already exists ($new_filename)\n";
- }
- else {
- rename "$dir$_", "$dir$new_$filename";
- print "File $_ renamed to $new_filename\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement