How to get number of pages in Tiff file?

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, helmut, xnview

Post Reply
punith8626
Posts: 48
Joined: Thu Feb 02, 2017 11:22 am

How to get number of pages in Tiff file?

Post 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 ?
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

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

Post 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
punith8626
Posts: 48
Joined: Thu Feb 02, 2017 11:22 am

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

Post 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
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

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

Post 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.
punith8626
Posts: 48
Joined: Thu Feb 02, 2017 11:22 am

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

Post by punith8626 »

-Info will give all information about the file. But I need to have only number of pages.
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

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

Post 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
0617
Posts: 2
Joined: Wed Mar 15, 2017 7:36 am

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

Post 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:\>
cday
XnThusiast
Posts: 3973
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

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

Post 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...
Post Reply