in reply to rename file name in directory and subdir
If so something like this might work, although I can't test it on windows at the moment:
#!/usr/bin/perl use strict; use warnings; my $path = 'C:\folder1\folder2\'; my @newName = split (/\\/, $path); shift(@newName); my $rename = join(".", @newName); opendir (my $directory, $path) or die $!; while(readdir $directory) { next if $_ =~ m/^\./; my $fileName = "$rename" . ".$_"; rename $_, $fileName; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: rename file name in directory and subdir
by choroba (Cardinal) on Aug 06, 2013 at 20:30 UTC | |
by mtmcc (Hermit) on Aug 06, 2013 at 20:40 UTC | |
by marinersk (Priest) on Aug 07, 2013 at 19:55 UTC | |
by mtmcc (Hermit) on Aug 07, 2013 at 20:17 UTC | |
|
Re^2: rename file name in directory and subdir
by starface245 (Novice) on Aug 06, 2013 at 20:35 UTC | |
by mtmcc (Hermit) on Aug 06, 2013 at 22:23 UTC |