Merge branch 'master' of feistymeow.org:feisty_meow
[feisty_meow.git] / scripts / files / change_prefix.pl
1 #!/usr/bin/perl
2
3 ##############
4 #  Name   : change_prefix
5 #  Author : Chris Koeritz
6 #  Rights : Copyright (C) 2002-$now by Author
7 ##############
8 #  Purpose:
9 #    Replaces all of the matching first portions of files in the current
10 #  directory with a different chunk.  The first parameter should be the old
11 #  prefix and the second parameter should be the new prefix.
12 ##############
13 #  This script is free software; you can redistribute it and/or modify it
14 #  under the terms of the GNU General Public License as published by the Free
15 #  Software Foundation; either version 2 of the License or (at your option)
16 #  any later version.  See "http://www.fsf.org/copyleft/gpl.html" for a copy
17 #  of the License online.  Please send any updates to "fred@gruntose.com".
18 ##############
19
20 require "filename_helper.pl";
21
22 local($first) = $ARGV[0];
23 local($second) = $ARGV[1];
24
25 #print "parms are: $first and $second \n";
26
27 if ( !length($first) || !length($second) ) {
28   print "change_prefix: requires two parameters--the old prefix to look for in this\n";
29   print "directory and the new prefix to replace the old suffix with.\n";
30   exit 0;
31 }
32
33 foreach $filename (&glob_list("./$first*")) {
34   local $new_name = $filename;
35   $new_name =~ s/$first/$second/g;
36 #print "old name $filename\n";
37 #print "new name will be $new_name\n";
38   system("mv \"$filename\" \"$new_name\"");
39 }
40
41