3 ###############################################################################
5 # Name : change endings #
6 # Author : Chris Koeritz #
7 # Rights : Copyright (C) 2002-$now by Author #
11 # Replaces all of the endings on files in the current directory with #
12 # a different ending. The first parameter should be the old ending and the #
13 # second parameter should be the new ending. #
15 ###############################################################################
16 # This script is free software; you can redistribute it and/or modify it #
17 # under the terms of the GNU General Public License as published by the Free #
18 # Software Foundation; either version 2 of the License or (at your option) #
19 # any later version. See "http://www.fsf.org/copyleft/gpl.html" for a copy #
20 # of the License online. Please send any updates to "fred@gruntose.com". #
21 ###############################################################################
23 # change_endings: takes all of the files in the current directory ending in $1
24 # and modifies their suffix to be $2.
26 require "filename_helper.pl";
28 #require "importenv.pl";
29 #require "inc_num.pl";
31 local($first) = $ARGV[0];
32 local($second) = $ARGV[1];
34 #print "parms are: $first and $second \n";
36 if ( !length($first) || !length($second) ) {
37 print "change_endings: requires two parameters--the old suffix to look for in this\n";
38 print "directory and the new suffix (without dots) to change the old suffix to.\n";
42 foreach $filename (&glob_list("./*$first")) {
43 #old print "file=$filename\n";
44 #old local($ext_temp) = &extension($filename);
45 #old print "ext is: $ext_temp\n";
46 #old local($no_ext) = &non_extension($filename);
47 #old print "cmd is: mv \"$filename\" \"$no_ext$second\"\n";
48 #old system("mv \"$filename\" \"$no_ext$second\"");
50 local $new_name = $filename;
51 $new_name =~ s/$first/$second/g;
52 #print "old name $filename\n";
53 #print "new name would be $new_name\n";
55 system("mv \"$filename\" \"$new_name\"");