Re: OT: shell scripts and spaces in file/folder names
On Sat, 19 Apr 2003, Troy Arnold wrote:
> #!/usr/bin/perl
> ## rename files, straight from the Perl Cookbook
>
> my $op = shift or die "Usage: $0 expr [files]\n";
> chomp(@ARGV=<STDIN>) unless @ARGV;
> for (@ARGV) {
> my $was= $_;
> eval $op;
> die $@ if $@;
> rename($was,$_) unless $was eq $_;
> }
>
> __END__
>
> usage:
> ren.pl "s/ /-/g" files
"files" must be pre-defined to exclude directories or not ??
> quicker and less error prone than one-liners.
it will also rename directories, not just files .. that you may or may not
have wanted
i always have excludes after my "ls" for everything except "this|that"
-- there is no one script that will work for all cases ...
that's why there are lots of variations of the same thing
-- fun to see this cat still being skinned a dozen different ways
c ya
alvin
Reply to: