Below is a (non-finished) script that trys to run a linux viewer
called eog (eye of gnome) in a script that will eventually allow me to
power thru long lists of image files and rename them as I go.
The idea was a cmdline tool that would pop up a view of each image
then query user for new name. Kill that process and move on to next
item in list.
I couldn't think of any better way than to query `ps' for the pid and
run `kill' on it. However even that isn't working.
But I wondered if there is a better way of doing this that is still
fairly basic?
#!/usr/local/bin/perl -w
$question = "New name please => ";
$ext=shift;
$ls_proc = "ls *.$ext";
open(LS_PROC," $ls_proc|");
while(<LS_PROC>){
chomp;
push @ls_array,$_;
}
for(@ls_array){
$pic = $_;
system("eog $pic &");
print $question;
chomp ($newname = <STDIN>);
print "<$newname>\n";
qx(cp -a $pic "$newname.$ext");
## rename $_ "$newname.$ext";
open(PS_PROC,"ps wwaux|");
while(<PS_PROC>){
chomp;
if($_ =~ /^$ENV{LOGNAME}.*eog.*\.jpg$/){
my $line = $_;
print "hpdb \$line = $line\n";
<STDIN>;
$pid = (split(/\s+/,$line))[1];
print "hpdb \$pid = $pid\n";
<STDIN>;
print "kill -15 on $pid?\n";
$ans = <STDIN>;
if ($ans eq "y"){
print "Killing -15 on pid <$pid>\n";
qx(kill -15 $pid);
}
}
}
close(PS_PROC);
}
close(LS_PROC);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]