Page 1 of 1

How to get number of pages in Tiff file?

Posted: Thu Feb 02, 2017 11:26 am
by punith8626
Hello,

I have multipage tiff and I wanted to get number of pages in tiff.

Is there any way to get number of pages in tiff page?.If so what is the command for the same ?

Re: How to get Number of pages in Tiff Page ?

Posted: Thu Feb 02, 2017 11:37 am
by cday
punith8626 wrote:I have multipage tiff and I wanted to get number of pages in tiff.

Is there any way to get number of pages in tiff page?.If so what is the command for the same ?
You want to extract the pages of a multi-page TIFF file to separate TIFF files, or possibly just read the number of pages?

The command to extract the pages of a multi-page file is:

Code: Select all

-xall

Re: How to get Number of pages in Tiff Page ?

Posted: Thu Feb 02, 2017 12:13 pm
by punith8626
I want to just read the number of pages in tiff.

Like in image magic we use command identify to read the number of pages in tiff

Re: How to get Number of pages in Tiff Page ?

Posted: Thu Feb 02, 2017 12:23 pm
by cday
punith8626 wrote:I want to just read the number of pages in tiff.

Like in image magic we use command identify to read the number of pages in tiff
This should be the NConvert equivalent, if you could check if it shows the number of pages:

Code: Select all

-info             : Display informations only
The procedure for creating a listing of the NConvert Help file is given in this post, if you don't have one already.

Re: How to get Number of pages in Tiff Page ?

Posted: Thu Feb 02, 2017 12:29 pm
by punith8626
-Info will give all information about the file. But I need to have only number of pages.

Re: How to get Number of pages in Tiff Page ?

Posted: Thu Feb 02, 2017 12:42 pm
by cday
punith8626 wrote:-Info will give all information about the file. But I need to have only number of pages.
There is no specific option for that as far as I know... :(

ImageMagick has many more options, but NConvert also has some advantages including faster processing, I believe, and the ability to process input and output files in directories... :D

Re: How to get Number of pages in Tiff Page ?

Posted: Wed Mar 15, 2017 7:56 am
by 0617
Type in command line. Replace 1.tif with your file name.
With leading space though.

Code: Select all

S:\>for /F "usebackq tokens=2 delims=:" %i in (`nconvert -info 1.tif ^| find "Page(s)"`) do @echo %i
 3
S:\>
Or create command file pages.cmd
No leading space!

pages.cmd

Code: Select all

@echo off
set PAGES=
for /F "usebackq tokens=2 delims=:" %%i in (`nconvert -info %1 ^| find "Page(s)"`) do set "PAGES=%%i"
set "PAGES=%PAGES:~1%"
echo %PAGES%
set PAGES=
Result:

Code: Select all

S:\>pages 2.tif
6
S:\>

Re: How to get number of pages in Tiff file?

Posted: Wed Mar 15, 2017 8:45 am
by cday
Thank you for posting your solution 0617! :D

Sadly the very cryptic notation required rather limits the use of cmd.exe by casual users to provide solutions to problems...