batch convert ONLY first tif (tif has two files)

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Posts: 6
Joined: 2017-11-04T04:03:17-07:00
Authentication code: 1152

batch convert ONLY first tif (tif has two files)

Post by jessicaC » 2018-01-07T15:47:52-07:00

Hi everyone

So I have a tif that has two files inside. I only need to convert one

convert 1.tif[0] 1.jpg
covert 1.tif[0] n/1.tif

works fine

But how do I do it in batch in Windows?

For example if I simply want to convert and place into subfolder.

Code: Select all

$raws=Get-ChildItem . | where {$_.Extension -match "tif"}
foreach ($raw in $raws) {
convert  $raw[0] n/$raw

doesn't work

User avatar
Posts: 22789
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: batch convert ONLY first tif (tif has two files)

Post by fmw42 » 2018-01-07T19:02:02-07:00

You code looks more like Unix shell script syntax than Windows batch syntax. Sorry, I do not know Windows scripting syntax.

Posts: 9847
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: batch convert ONLY first tif (tif has two files)

Post by snibgo » 2018-01-07T20:25:25-07:00

@jessicaC: What version of IM are you using? What script language are you using? On Windows, it could be BAT or bash or Powershell or many others.

You say "doesn't work". What happens? Any error messages?

The script language is critical. For example, bash doesn't allow "[" in identifiers, so "$raw[0]" will expand raw successfully, but windows BAT (and possibly Powershell) does allow "[" in identifiers.
snibgo's IM pages:

Post Reply