Hi all.
I've got the following code to standarize my movie titles:
#!/usr/bin/perl use strict; use warnings; for (<@ARGV>) { # Change spaces to _ my $new = $_; $new =~ s/\s/_/g; rename($_, $new) or die "Cannot rename '$_' to '$new': $!"; # Capitalize my $new2 = $new; $new2 =~ s/(^|_)(\w)/$1\U$2/g; print "$_ -> $new2\n"; rename($new, $new2) or die "Cannot rename '$new' to '$new2': $!"; }
The problem is exactly because the files have spaces in the name. I've searched for a solution and I only find that I have to quote the argument; this partially works, as it works if I use something like titulize.pl "*.avi", but not if I use titulize.pl "test spacefull name.avi". Moreover, I'd like if possible to pass the file names as in the normal way, as every other command line program.
Could somebody bring me some light about how to pass file names with spaces as arguments?
Best regards.
Update: Excuse me all of you who have send me your ideas; I'm having some problems with my computer, so I will answer all of you as soon as I could try your solutions.
In reply to Spaces in file names passed as arguments by txixco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |