in reply to Automating cmd prompt command execution

I don't understand what you mean by 1. and 2. The current directory is the one in which the program is running, unless you change it. The rest can be implemented by checking the extension:
#!/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

    thanks a lot for the help. What I meant was, the kindletool.exe tool will be kept in a particular path. Ex : C:\Users\user\Desktop\Convert. So this code which is given, will run from bin folder of perl. I want to run it on the above mentioned path.

      Ignore my reply !! I figured it out...i was bit confused :) now its clear..one more help, when the code is done running, I should get a message saying " Do u want to continue? Press Y to run the program again or press N to exit"

        Use print to show the message, use readline to get the answer. Wrap the whole program body in a loop to repeat it:
        my $run = 'y'; while ($run =~ /^y/i) { ... print 'Do u want to continue? '; $run = readline; }
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ