#!/usr/bin/perl # renhtm: a perl program to rename all '*.html' files in the # current directory to '*.html' # # Version 1.0b # # You may need to change the /usr/bin/perl command in the # first line to point to your copy of the perl interpreter. # # This program only works correctly on platforms which support # long filenames such as UNIX, OS/2, Macintosh and Windows NT. # It will not work correctly on MS-DOS, since the source and # destination files will be identical (MS-DOS cuts off the # trailing 'l' in '.html') # # For more information about perl, consult: # http://www.eecs.nwu.edu/perl/perl.html # # Copyright 1994 Walter Shelby Group Ltd. # All rights reserved worldwide. # print "------------------------------------------------\n"; print " renhtm: renames all '.html' files to '.html'\n"; print "\n This program is useful when copying HTML files\n"; print " from MS-DOS to a platform with long filenames.\n"; print "\n Copyright 1994 Walter Shelby Group Ltd.\n"; print "------------------------------------------------\n"; $FileCount = 0; #For MacPerl, use instead the command: opendir(DIR, ''); opendir(DIR, '.'); #For MacPerl, use instead the command: @FileList = grep(/.*\.html.*/, readdir(DIR)); @FileList = grep(/\.html$/, readdir(DIR)); closedir(DIR); foreach $File(@FileList) { $InFile = $File; $OutFile = "\L$File".".html"; print "$InFile => $OutFile "; $Success = rename ($InFile,$OutFile); # you may want to comment this line out for your system chmod (0644,$OutFile); if ($Success) { print "\n"; } else { $RenameFailed++; print " (rename failed)\n"; } $FileCount++; } print "------------------------------------------------\n"; print "$FileCount .html files found:\n"; $SuccessfullyRenamed = $FileCount - $RenameFailed; print "* Successfully renamed $SuccessfullyRenamed file(s) to .html.\n"; print "* Failed to rename $RenameFailed file(s).\n";