0

How can I combine two windows cmd as single cmd.

My objective : At present I have to create the folder in destination and than run the convert cmd separately.

Solution required : I want to merge both the cmd as single cmd which takes care of below requirement.

Note : Both the sequence are available in notepad, which is copied to cmd prompt.

# Create folder in destination if not available
IF NOT EXIST "F:\Input\Folder\001" md "F:\Output\Folder\001
IF NOT EXIST "F:\Input\Folder\002" md "F:\Output\Folder\002


# converts the image format from source to destination
Convert input.tiff output.jpg (imagemagick)
Convert input_1.tiff output_1.jpg (imagemagick)
3
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Mar 10, 2022 at 4:43
  • So essentially you're asking a solution to combine both these scripts, right? Commented Mar 10, 2022 at 5:21
  • @SaaranshGarg , Yes that's right. Commented Mar 10, 2022 at 5:31

1 Answer 1

0

I have to create the folder in the destination and then run the convert command separately.

Yes, as they are executed by Windows and ImageMagick, respectively. ImageMagick doesn't have any method to create new directories (as far as I am aware).

I want to merge both commands as single commands.

You can potentially replace the individual folder creation commands with a single Windows FOR loop, but likely only if the directory names follow a very specific pattern.

As for ImageMagick, there is support for processing image names in bulk in a directory. But you would still need to run that same command twice.

Note that you can run two individual commands at once with a double ampersand (&&) separating them. In this case, the second command will only execute if the first command is successful.

If you don't care about successful creation of the folder, then you could just use a single ampersand (&) to separate them.

In your case, commands one and three and then commands two and four would be combined this way.

6
  • Yes, i tried this and works fine. But if the folder exists than the second command aborts or fails to execute. Commented Mar 10, 2022 at 9:19
  • As you explained above, the folders are created once so the first set of cmd is success but again second time the folder exist , but than the second command fails. Does this work with batch format Commented Mar 10, 2022 at 9:32
  • @Travelz_ please read the If you don't care about successful creation of the folder ... sentence again.
    – Stephan
    Commented Mar 10, 2022 at 11:10
  • @Stephan , I note your point. I have used the single ( &,) but still it failed in running second command. Commented Mar 10, 2022 at 11:53
  • Then the problem is probably with the second command (btw: it's a batch file - there is no need to squeeze several commands into one line. Just use one command per line.). How does it fail? Any messages on screen?
    – Stephan
    Commented Mar 10, 2022 at 11:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .