The problem you're having is on the command line. When you do
the results of ls become the command line for mp3concat, but if ls encounters filenames with embedded spaces, they'll appear as separate tokens on the command line. By the time these tokens get into @ARGV, it's too late.mp3concat -s 700 `ls`
One approach to fixing this is to have mp3concat take directory names as arguments (either instead of or in addition to filenames). Then, within the code, you could do something like
With a little more work, this can handle hierarchies, as well.foreach my $arg ( @ARGV ) { doDir($arg), next if -d $arg; doFile($arg) if -f $arg; } ... sub doDir { my $dir = @_; opendir(D, $dir) or die "$dir: $!"; foreach my $file ( grep { -f } readdir(D) ) { doFile($file); } closedir(D); }
Another alternative is to use File::Find to traverse directories, looking for .mp3 files. If you search around the monastary, you'll find plenty of examples of using File::Find.
In reply to Re: filenames with spaces causing problems
by dws
in thread filenames with spaces causing problems
by drake50
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |