[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pan-users] 0.11.3 question
From: |
John Aldrich |
Subject: |
Re: [Pan-users] 0.11.3 question |
Date: |
Tue, 27 May 2003 17:19:48 -0400 |
User-agent: |
KMail/1.4.3 |
On Tuesday 27 May 2003 04:36 pm, Vadim Berezniker wrote:
> Eric Ortega wrote:
> > On Fri, May 23, 2003 at 08:23:49PM -0400, Wolf J. Flywheel wrote:
> >> As far as I know, there's no way built into Pan, but if you're using
> >> Bash as your command shell, you can save them all in the same place and
> >> do something like this:
> >>
> >> for f in *.jpg ; do mv "${f}" "BobsCat${f}" ; done
> >
> > Those quotes and squiggly-brackets are unnecessary AFAIK.
> >
> > for i in `ls *.jpg` ; do mv $i BobsCat$i; done
> >
> > is fine.
>
> You can get into some "deep shit" if you remove the quotes and the
> filename has spaces in it. =)
>
Here's a handy little perl script someone whipped up to convert spaces to "_"
in filenames for me.... I'm sure a good perl monger could make it a bit more
robust and do more things much like was asked for originally... ;-)
-=-=-=-=-=-=-
#!/usr/bin/perl
# GLOBALS ##################################################################
use strict;
use Symbol;
use File::Basename;
use Getopt::Std;
use vars qw/ $ARGV0 /;
sub main ();
sub show_help();
$ARGV0 = basename($0);
main();
die "Unreachable code reached";
# MAIN BODY ################################################################
sub main () {
my(%opts);
my($dir, $file);
my($p) = gensym;
unless (getopts('hv', \%opts)) {
show_help();
exit(1);
}
if ($opts{'h'}) {
show_help();
exit(0);
}
unless ($#ARGV == 0) {
show_help();
exit(1);
}
unless (open($p, "find '$ARGV[0]' | sort -r|")) {
print STDERR "open|: find '$ARGV[0]' | sort -r: $!\n";
exit(1);
}
while (<$p>) {
chomp();
$dir = dirname($_);
$file = basename($_);
next unless ($file =~ s/\s/_/g);
unless (rename($_, "$dir/$file")) {
print STDERR "rename: $_ -> $dir/$file: $!\n";
exit(1);
}
print "$_ -> $dir/$file\n" if ($opts{'v'});
}
close($p);
exit(0);
}
# SUB FUNCS ################################################################
sub show_help () {
print STDOUT "
usage: $ARGV0 [<opts>] <directory>
-h show help. causes this message to be shown.
-v verbose. show names as files are renamed.
All entries under given diretory containing spaces in their
named will be renamed using '_' characters instead.
\n";
return();
}
- [Pan-users] 0.11.3 question, Anthony, 2003/05/23
- Re: [Pan-users] 0.11.3 question, Wolf J. Flywheel, 2003/05/23
- Re: [Pan-users] 0.11.3 question, Eric Ortega, 2003/05/27
- Re: [Pan-users] 0.11.3 question, Vadim Berezniker, 2003/05/27
- Re: [Pan-users] 0.11.3 question,
John Aldrich <=
- Re: [Pan-users] 0.11.3 question, Eric Ortega, 2003/05/27
- [OT] On renaming files - was [Pan-users] 0.11.3 question, Wolf J. Flywheel, 2003/05/27
- Re: [OT] On renaming files - was [Pan-users] 0.11.3 question, Duncan, 2003/05/28
- Re: [OT] On renaming files - was [Pan-users] 0.11.3 question, Wolf J. Flywheel, 2003/05/28
- Re: [Pan-users] 0.11.3 question, Eric Ortega, 2003/05/27
- Re: [Pan-users] 0.11.3 question, gaw zay, 2003/05/27
- Re: [Pan-users] 0.11.3 question, Anthony, 2003/05/27
- Re: [Pan-users] 0.11.3 question, Eric Ortega, 2003/05/27
- Re: [Pan-users] 0.11.3 question, Eric Ortega, 2003/05/27