Page 1 of 1

batch convert ONLY first tif (tif has two files)

Posted: 2018-01-07T15:47:52-07:00
by jessicaC
Hi everyone

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

convert 1.tif[0] 1.jpg
or
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

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

Posted: 2018-01-07T19:02:02-07:00
by fmw42
You code looks more like Unix shell script syntax than Windows batch syntax. Sorry, I do not know Windows scripting syntax.

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

Posted: 2018-01-07T20:25:25-07:00
by snibgo
@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.