You may sometimes want to rename multiple files at once, or add or remove them from CVS or other version-ing system. Or you just want to do things using a file from the system and some other file that is not on the system.

You can use PERL and the find command to do this,

If the only way to obtain the name of the second file is with a regular expression, a good solution is to use find combined with a perl script.

Renaming multiple files Edit

Here is an example on how to rename multiple files from various directories. Let's say you have many files named "list.rhtml" and you want to rename them to "index.rhtml". you can write a simple perl script named

use strict;

my $file1 = $ARGV[0];
my $file2 = $file1;

$file2 =~ s/list/index/; 

print "Renaming $file1 to $file2\n";

system "mv $file1 $file2";

Then type in a terminal this find command:

chmod +x ./
find . -name "list.rhtml" -exec ./ '{}' \;
The same way you can call other bash commands with system on this files, like add them to CVS or anything else.

From HowTo Wiki, a Wikia wiki.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.