in reply to Automating cmd prompt command execution
#!/usr/bin/perl use warnings; use strict; for my $file (glob '*.mobi *.prc *.epub') { my ($ext) = $file =~ /\.(.*)/; if ($ext =~ /mobi|prc/i) { my $status = system qw{ kindletool.exe strip_source }, $file; warn "Failure $status: $file" if $status; } elsif (lc $ext eq 'epub') { (my $newname = $file) =~ s/\.epub$/.zip/; rename $file, $newname or warn "Failure $!: $file"; } }
For details, see glob, system, lc, rename.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Automating cmd prompt command execution
by Anonymous Monk on Sep 08, 2015 at 10:08 UTC | |
by Anonymous Monk on Sep 08, 2015 at 10:20 UTC | |
by choroba (Cardinal) on Sep 08, 2015 at 11:32 UTC |