in reply to Why does this only work correctly as root?

I've now discovered the cause of this- Brackets in the filenames (Arrgh- root was a red herring caused by my test file) I've added the suggested error checking and two more sets of rename statements to cope with these at present, which appears to be working. Do you have an example of using Opendir for this sort of thing? I managed to get it to run MKVMerge for every file, but I can't get it to play nice with the extensions. Cheers
  • Comment on Re: Why does this only work correctly as root?

Replies are listed 'Best First'.
Re^2: Why does this only work correctly as root?
by jethro (Monsignor) on Aug 10, 2009 at 08:37 UTC
    my $f; Opendir($f,"."); my $filename; while ($filename=readdir($f)) { if ($filename=~/\.avi$/) { $filename=~s/([ \[\];$'"()])/\\$1/g; #adds \ before spaces, bracke +ts and other special chars ... } }

    Note I do not know how escaping works in windows (where \ is dir separator) or what special chars make problems there. So above probably needs some more refinement to work on both platforms.