convert tif - prevent renaming on single page

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
UniCav
Posts: 1
Joined: 2011-01-11T16:04:09-07:00
Authentication code: 8675308

convert tif - prevent renaming on single page

Post by UniCav »

I'm running convert from a shellexecute in an outlook vba to handle bulk attachments.
When they arrive the vba saves the attached TIF or PDF and then runs convert to separate the pages into sequentially numbered TIF's
However if someone sends a single page the resulting filename is File_Name_%02d.tif instead of just File_Name.tif or even File_Name_00.tif
Does anyone know of a way to prevent it from adding the suffix if it's only a single page?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert tif - prevent renaming on single page

Post by fmw42 »

write a script to test the number of frames and use a conditional to write the filename in two different ways depending upon if there are more than one frame.

see http://www.imagemagick.org/script/escape.php %n for number of scenes

convert rose: rose: rose: rose3.tif
scenes=`convert rose3.tif -format %n info: | head -n 1`
if [ $scenes -eq 1 ]; then
#write name for one scene
else
#write name for multple scenes
fi

In this case you will get scenes=3

Windows uses should see the equivalent concepts in http://www.imagemagick.org/Usage/windows/
Post Reply