20070203

voice copy



#!/usr/bin/perl

use File::Copy;

if ($ARGV[0] =~ /\/$/) {
$src = $ARGV[0];
} else {
$src = $ARGV[0] . "/";
}
if ($ARGV[1] =~ /\/$/) {
$dst = $ARGV[1];
} else {
$dst = $ARGV[1] . "/";
}

opendir(DIRHANDLE, $src) || die "Cannot opendir $src: $!";
foreach $fname (readdir(DIRHANDLE)) {
if (!($fname =~ /^\./))
{
$file = $src . $fname;
@t = localtime ( ( ( stat ( $file ) ) [9] ) );
@f = split(/[(.]/,$fname);
$s = sprintf("@f[0]_%04d%02d%02d_%02d%02d%02d.wav",$t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0]);
printf("%s\t%s\n",$file,$dst . $s);
copy($file, $dst . $s) || die "Cannot rename $file to $s: $!";
}
}
closedir(DIRHANDLE);







  • Platform : Unix
  • Script : perl
  • desc :

    An improved version that copies the files from source directory to destination directory after renaming.


voice rename


1 #!/usr/bin/perl
2
3
foreach(@ARGV){
4 @t = localtime ( ( ( stat ( $_ ) ) [9] ) );
5 @f = split(/[(.]/,$_);
6 $s = sprintf("@f[0]_%04d%02d%02d_%02d%02d%02d.wav",$t[5]+1900,$t[4]+1,$t[3],$t[2],$t[1],$t[0]);
7 printf("%s\t%s\n",$_,$s);
8 rename($_,$s) || die "Cannot rename $_ to $s: $!";
9 }



  • Platform : perl
  • Script : Rename voice files
  • desc :

    This is a script to batch rename the voice calls recorded on my phone to __