Dan Anderson wrote: > > Is it possible to do something to a string so that it gets escaped for a > shell command (i.e. if I'm executing a command and I have the file name > "foo's bar.jpg" it will be escaped to: "foo\'s\ bar.jpg"? > > Right now the following script is giving me problems because whenever > the mv command is executed the file names never get properly escaped.
Better to use Perl's rename() function or File::Copy::move > #! /usr/bin/perl > > use warnings; > use strict; > > my @output = `ls`; > my $count = 1; > > while ($_ = shift @output) { > chomp $_; > # print $_, "\n"; > # $_ =~ s/ /\\ /; > print "mv ./${_} ./${count}.jpg\n" unless $_ =~ /rename.pl/; > $count++; > } #! /usr/bin/perl use warnings; use strict; use File::Copy; my $count = 0; foreach ( <*> ) { # use glob to get file names next if /rename\.pl/; move( $_, ++$count . '.jpg' ) or warn "Cannot move $_ to $count.jpg: $!"; } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]