Created
March 5, 2012 03:41
-
-
Save satojkovic/1976414 to your computer and use it in GitHub Desktop.
Replace file extension txt to csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use File::Basename; | |
use File::Spec; | |
use File::Copy; | |
my $file = shift; | |
if( !defined($file) ) { die "Usage : $0 <text file>"; } | |
my ($fn, $path, $ext) = fileparse($file, 'txt'); | |
if( $ext ne 'txt' ) { die "$file is not text file..."; } | |
my $new_file = File::Spec->catfile($path, join("", $fn, "csv")); | |
if( copy $file, $new_file ) { | |
print "copy $new_file success!\n"; | |
} | |
else { | |
print "copy $new_file failed...\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment