Rename a file : rename « File « Perl






Rename a file

   

#!/usr/bin/perl -w

use strict;

print "enter new file name: ";
chomp(my $newname = <STDIN>);
rename "../yourData.dat", $newname or die "rename failed: $!\n";
print "file moved successfully!\n";

   
    
    
  








Related examples in the same category

1.Rename a group of files with a common extension?
2.Renaming Files: rename(OLDFILENAME, NEWFILENAME);
3.Renaming a file before accidental deletion