
yasdel
Novice
Sep 27, 2010, 9:37 AM
Post #1 of 2
(1275 views)
|
Change the name of files dynamically
|
Can't Post
|
|
Hi Guys. I am going to use a perl script that searches for .wma files in the specified directory and changes their audio properties. The problem I have is how to change name of each file dynamically. Let's say if : original file => file1.wma converted file => file1_cnvrt.wma The command sox is used for this purpose and has this notation : $cmd="sox $file -r $Fs file1.wma file1_cnvrt.wma" my code is here. I simply need a suggestion for ??? in the code. I would appreciate if you could suggest the simplest possibility that can be understandable for me too. Thanks in advance. my code :
$dirtoget="/tsi/hadrien/deldjoo/Desktop/Ads/Sony_Serie_E_BALADEURS_Multimedia"; opendir(IMD, $dirtoget) || die("Cannot open directory"); @thefiles= readdir(IMD); closedir(IMD); $Fs=16000; # [Hz] foreach $file (@thefiles){ if ($file=~m/.+\.wav/){ # $file=~m/.+\.wma/ gives true or false dependig if $file matches the pattern /.+\.wav/ $cmd="sox $file -r $Fs $file ????" system($cmd); # here the command is called by the system } else {print "OK \n";} } My best, YAS
(This post was edited by yasdel on Sep 27, 2010, 10:01 AM)
|