nice new tool to show version of feisty meow
[feisty_meow.git] / scripts / files / change_suffix.pl
1 #!/usr/bin/perl
2
3 ##############
4 #  Name   : change_suffix
5 #  Author : Chris Koeritz
6 #  Rights : Copyright (C) 2002-$now by Author
7 ##############
8 #  Purpose:
9 #    Replaces all of the matching endings on files in the current directory
10 #  with a different ending.  The first parameter should be the old ending and
11 #  the second parameter should be the new ending.
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_suffix: requires two parameters--the old suffix to look for in this\n";
29   print "directory and the new suffix 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
39   system("mv \"$filename\" \"$new_name\"");
40 }
41
42