Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help! Need a batch file to merge thousands of tiff files.

2,592 views
Skip to first unread message

SRB_Dallas

unread,
Mar 7, 2011, 12:57:55 PM3/7/11
to
I have a directory on a Win OS with thousands of TIFF files. An
example of the files are:

32202900_55967.tif
32202900_56130.tif
32206130_57427.tif
32206130_57515.tif
32209667_60298.tif
32209667_60508.tif
and so on...

As you can see, the first 8 digits of some of the filenames are
exactly the same. These actually belong together as one file. I need a
script that joins 2 (or more) TIFF files together which have the same
first 8 digits AND removing the underscore and everything after it. So
based on the above example, the final output should look like this:

32202900.tif
32206130.tif
32209667.tif
and so on...

Thanks in advance.

Frank P. Westlake

unread,
Mar 7, 2011, 1:01:46 PM3/7/11
to
"SRB_Dallas"
news:098b66ad-fad3-47d7...@j35g2000prb.googlegroups.com...
> I need a script that joins 2 (or more) TIFF files together ...

How are TIFF files joined? Are they merely stuck together in sequential
order, or is there an application that you are aware of which does the
joining?

Frank


SRB_Dallas

unread,
Mar 7, 2011, 1:08:40 PM3/7/11
to
On Mar 7, 12:01 pm, "Frank P. Westlake" <frank.westl...@gmail.com>
wrote:

Yes. Stuck together in sequential order.

01MDM

unread,
Mar 7, 2011, 1:30:39 PM3/7/11
to

> Yes. Stuck together in sequential order.

If it realy need not any special utilities:

@echo off

cd.>result.tiff
for /f "tokens=*" %%i in ('dir /b *.tiff') do (

copy /b result.tiff+"%%i" result.tiff

)

foxidrive

unread,
Mar 7, 2011, 2:09:43 PM3/7/11
to

How do you 'stick' them together at the moment? Appended? I don't
think .tiff files or any other graphic formats work like that.


--
Regards,
Mic

SRB_Dallas

unread,
Mar 7, 2011, 2:56:45 PM3/7/11
to
Apologies! I should clarify what I am trying to do here. I am going to
convert all files to PDFs using Adobe's Batch Processing option.

Then, I want one script that runs through the directory that combines
all the PDFs that are supposed to go together. To determine what's
"supposed" to go together, I would have it check the numbers before
the underscore. Same numbers means one file (regardless of how it is
sequenced once attached, so appending it is totally fine)

So,

32202232_452435.pdf
32202232_546725.pdf
32202232_523452.pdf

becomes 32202232.pdf

and

35846945_878606
35846945_676976

becomes

35846945.pdf

and so on...

I have thousands of files like that in the directory.

Again, thanks for your patience.

foxidrive

unread,
Mar 7, 2011, 3:10:40 PM3/7/11
to


Run this in an empty folder to see how this works.

It creates some dummy PDF files, moves them to a folder with the name of
the filename prefix, and then appends all the groups of files to a
prefixfilename.pdf in the current folder.

It leaves the originals in the first group of folders in case you need them.

Do be sure that the folder has no folders in it before you start this as
they can be altered.


Remove the lines starting with echo to run it on your files.


@echo off

echo abc>32202232_452435.pdf
echo def>32202232_546725.pdf
echo ghi>32202232_523452.pdf

echo 123 >35846945_878606.pdf
echo 456 >35846945_676976.pdf

for /f "tokens=1,2 delims=_" %%a in ('dir *.pdf /b') do (
md "%%a" 2>nul
move "%%a_%%b" ".\%%a\" >nul
)

for /f "delims=" %%a in ('dir /a:d /b') do (
copy /b "%%a\*.*" "%%a.pdf"
)


--
Regards,
Mic

Herbert Kleebauer

unread,
Mar 7, 2011, 3:56:04 PM3/7/11
to
foxidrive wrote:

> for /f "delims=" %%a in ('dir /a:d /b') do (
> copy /b "%%a\*.*" "%%a.pdf"
> )

Maybe that's what the OP asked for, but that doesn't give
a valid pdf file. You have to use a program which concatenate
the pdf files (there should be a few free ones).

foxidrive

unread,
Mar 7, 2011, 4:03:59 PM3/7/11
to
On 8/03/2011 07:56, Herbert Kleebauer wrote:
> foxidrive wrote:
>
>> for /f "delims=" %%a in ('dir /a:d /b') do (
>> copy /b "%%a\*.*" "%%a.pdf"
>> )
>
> Maybe that's what the OP asked for, but that doesn't give
> a valid pdf file.

Yes, I don't know what he intends to do with them. They started out as
tif files if you recall. :)

> You have to use a program which concatenate
> the pdf files (there should be a few free ones).

He can ask for further assistance if needed.


--
Regards,
Mic

SRB_Dallas

unread,
Mar 7, 2011, 4:25:18 PM3/7/11
to
Hey guys,

Okay, I ran foxidrive's script on an empty folder. After running it,
it did create a bunch of dummy pdf files in the same folder with the
EXACT filename (not just the prefix). Also, it didn't then group all
the ones that had to go from the original folder to the new files.

Stumped.

billious

unread,
Mar 7, 2011, 4:29:18 PM3/7/11
to

"SRB_Dallas" <sach...@gmail.com> wrote in message
news:dae00428-47e0-4321...@o30g2000pra.googlegroups.com...


You haven't shown the syntax of the adobe line to invoke the batch-combine
option...

This solution developed using XP
It may work for NT4/2K

----- batch begins -------
[1]@echo off
[2]setlocal enabledelayedexpansion
[3]for %%i in (start combined) do (set %%i=)
[4]for /f "tokens=1,2delims=_" %%i in ( ' dir /b /o:n /a-d *_*.pdf ' ) do (
[5]if "%%i"=="!start!" (
[6]set combined=!combined! %%i_%%j
[7]) else (
[8]if defined combined ECHO adobe switches outname=!start!
innames=!combined!
[9]set combined=%%i_%%j
[10]set start=%%i
[11])
[12])
[13]if defined combined ECHO adobe switches outname=%start%
innames=%combined%
------ batch ends --------

Lines start [number] - any lines not starting [number] have been wrapped and
should be rejoined. The [number] that starts the line should be removed

The spaces surrounding the single-quotes are for emphasis only. The SPACES
are not required but the single-quotes ARE required.

%varname% will be evaluated as the value of VARNAME at the time that the
line is PARSED. The ENABLEDELAYEDEXPANSION option to SETLOCAL causes
!varname! to be evaluated as the CURRENT value of VARNAME - that is, as
modified by the operation of the FOR

foxidrive

unread,
Mar 7, 2011, 4:31:32 PM3/7/11
to

I suspect that your filenames don't conform to the examples you gave, if
you copy and pasted the code.

Do be aware that the PDF files it will create are not legal PDF files.
They are just appended copies, but that is what you asked for.


--
Regards,
Mic

SRB_Dallas

unread,
Mar 7, 2011, 4:56:52 PM3/7/11
to
foxidrive - worked! I accidentally hit a quote on the keyboard and
didn't notice it (dumb move, I know!). Thank you so much!

billious - Sorry I was so involved with getting foxidrive's script to
work, and refreshed to see yours as well. Thanks to you too for
helping out!

FileGod

unread,
Mar 18, 2011, 1:42:34 PM3/18/11
to
foxidrive <foxi...@gotcha.woohoo.invalid> wrote:
>How do you 'stick' them together at the moment? Appended? I don't
>think .tiff files or any other graphic formats work like that.

The only graphics format I know of it text format are ANSI & Rip
Graphics, I think there there are others but these are very low
resolution, ANSI max is 16 colors & as I recall Rip is 256 colors.
In the past I did copy Animated Rip Graphics together using nothing
but the basic copy command & had no problem in the results.
As I recall there are a few command line converters for Rip Graphics...

Sorry I have not replied sooner, I was in the hospital for a week.

http://www.filegod.netfirms.com

Herbert Kleebauer

unread,
Mar 20, 2011, 6:39:00 PM3/20/11
to
FileGod wrote:
> foxidrive <foxi...@gotcha.woohoo.invalid> wrote:

> >How do you 'stick' them together at the moment? Appended? I don't
> >think .tiff files or any other graphic formats work like that.
>
> The only graphics format I know of it text format are ANSI & Rip
> Graphics, I think there there are others but these are very low
> resolution, ANSI max is 16 colors & as I recall Rip is 256 colors.
> In the past I did copy Animated Rip Graphics together using nothing
> but the basic copy command & had no problem in the results.
> As I recall there are a few command line converters for Rip Graphics...

I always do a

copy /b *.jpg all.jpg

because then the you have much less files and the
pictures are easier to view.

But the question wasn't about pictures but pdf's.

foxidrive

unread,
Mar 21, 2011, 2:27:34 AM3/21/11
to
On 21/03/2011 09:39, Herbert Kleebauer wrote:
> FileGod wrote:
>> foxidrive<foxi...@gotcha.woohoo.invalid> wrote:
>
>>> How do you 'stick' them together at the moment? Appended? I don't
>>> think .tiff files or any other graphic formats work like that.
>>
>> The only graphics format I know of it text format are ANSI& Rip

>> Graphics, I think there there are others but these are very low
>> resolution, ANSI max is 16 colors& as I recall Rip is 256 colors.

>> In the past I did copy Animated Rip Graphics together using nothing
>> but the basic copy command& had no problem in the results.

>> As I recall there are a few command line converters for Rip Graphics...
>
> I always do a
>
> copy /b *.jpg all.jpg
>
> because then the you have much less files and the
> pictures are easier to view.

Hmmm. Are you pulling our legs? :) I tried that and only the first
image displayed.

Herbert Kleebauer

unread,
Mar 21, 2011, 2:40:49 AM3/21/11
to

Mark Blain

unread,
Mar 21, 2011, 11:37:09 AM3/21/11
to
SRB_Dallas <sach...@gmail.com> wrote in news:098b66ad-fad3-47d7-ad6d-
8c0767...@j35g2000prb.googlegroups.com:

Before considering how to select and name the files, you need a third-
party program that can join multiple single-page images into a valid and
usable multipage TIFF file. I found three no-cost ways to do so in MS-
Windows. I only tested the first one. You'll need to figure out which
works best for your file content.

1) IrfanView's "/append" command-line option, as documented at
<http://en.irfanview-forum.de/vb/showthread.php?345-Convert-multiple-
TIFF-files-to-a-single-multi-page-file>
(program available at http://www.irfanview.com)

2) ImageMagick's powerful but complex "convert" program:
http://www.imagemagick.org/script/index.php

3) LibTiff's "tiffcp" program, documented at
http://libtiff.maptools.org/man/tiffcp.1.html
(program available for Windows at
<http://gnuwin32.sourceforge.net/packages/tiff.htm>)

zhu...@gmail.com

unread,
Aug 24, 2012, 8:31:09 PM8/24/12
to
Hi, do you get the script?, I need :(

foxidrive

unread,
Aug 24, 2012, 10:00:28 PM8/24/12
to
If you describe your files/folder and provide a tool to merge the TIF files then someone might be able to help you.

--
Mic

Mark Blain

unread,
Aug 25, 2012, 7:26:24 PM8/25/12
to
foxidrive <foxi...@gotcha.woohoo.invalid> wrote in
news:amWZr.159$z07...@newsfe18.iad:

> If you describe your files/folder and provide a tool to merge the
> TIF files then someone might be able to help you.

I suspect the OP is requesting straight binary concatenation, but
that's just a guess. TIFF doesn't support animation, and multiple
images in the same TIFF file are possible but unusual.

foxidrive

unread,
Aug 25, 2012, 8:56:02 PM8/25/12
to
Are TIFF image files just binary images without headers or metadata?

If they aren't then binary concatenation isn't really appropriate, I'd think.


--
Mic

Bob

unread,
Aug 25, 2012, 10:30:09 PM8/25/12
to
zhu...@gmail.com typed the following on 8/24/2012 8:31 PM:
> El lunes, 7 de marzo de 2011 12:57:55 UTC-5, SRB_Dallas escribió:
>> I have a directory on a Win OS with thousands of TIFF files. An
>> example of the files are:
<snip>

El lunes, 7 de marzo de 2011 12:57:55 UTC-5, SRB_Dallas escribió:
On Monday, March 7, 2011 12:57:55 UTC-5, SRB_Dallas wrote:

Curious date posting.

Same question posted at the link below.

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26864426.html

foxidrive

unread,
Aug 25, 2012, 10:40:26 PM8/25/12
to
Good sleuthing Bob.

zhujrai can try there for the solution...


--
Mic

billious

unread,
Aug 25, 2012, 11:19:49 PM8/25/12
to
Using IRFANVIEW, a fine utility - and free for non-commercial use

(also very economical even for commercial use)

All lines indented 2 spaces. Any line not indented 2 spaces has been
wrapped from the previous line and will need to be recombined.

@ECHO OFF
::
:: Combine tiffs to pattern string1-string2.tif as string1.tif using
IRFANVIEW
::
:: Run in directory containing TIFFs
::
:: Establish destination directoryname & create
::
SETLOCAL enabledelayedexpansion
SET destdir=U:\dest
MD %destdir% 2>NUL
::
:: Scan for tiffs.
::
FOR /f "delims=-" %%i IN ( ' dir/b *-*.tif ' ) DO IF NOT EXIST
%destdir%\%%i.tif (
(SET srctiff=)
FOR /f %%a IN ( ' dir/b %%i-*.tif ' ) DO (
IF DEFINED srctiff (SET srctiff=!srctiff!,%%a
) ELSE (SET srctiff=%%a)
)
"C:\Program Files (x86)\IrfanView\i_view32.exe"
/multitif=^(%destdir%\%%i.tif,!srctiff!^) /cmdexit
)


I've assumed the standard location for i_view32 on a 64-bit system,
C:\Program Files (x86)\IrfanView\ which is NOT on the path. You would
need to adjust to its location on your system.

Be especially careful of the caret character (^) which must occur
DIRECTLY before the following parenthesis.

Mark Blain

unread,
Aug 26, 2012, 4:10:54 PM8/26/12
to
foxidrive <foxi...@gotcha.woohoo.invalid> wrote in
news:ive_r.261$cg5...@newsfe09.iad:

> On Sunday 26/08/2012 09:26, Mark Blain wrote:
>> [...]
>
> Are TIFF image files just binary images without headers or
> metadata?
>
> If they aren't then binary concatenation isn't really appropriate,
> I'd think.

True enough. The OP needs to clarify whether each input is a complete
TIF image file.

pavanku...@gmail.com

unread,
Oct 24, 2012, 10:23:16 AM10/24/12
to
On Monday, March 7, 2011 11:27:55 PM UTC+5:30, SRB_Dallas wrote:
> I have a directory on a Win OS with thousands of TIFF files. An
> example of the files are:
>
> 32202900_55967.tif
> 32202900_56130.tif
> 32206130_57427.tif
> 32206130_57515.tif
> 32209667_60298.tif
> 32209667_60508.tif
> and so on...
>
> As you can see, the first 8 digits of some of the filenames are
> exactly the same. These actually belong together as one file. I need a
> script that joins 2 (or more) TIFF files together which have the same
> first 8 digits AND removing the underscore and everything after it. So
> based on the above example, the final output should look like this:
>
> 32202900.tif
> 32206130.tif
> 32209667.tif
> and so on...
>
> Thanks in advance.



Hello

Pavan here just i need help i want java script to combine the 1 to 10 pdf file into a single pdf file through BATCH PROCESSING in adobe pro 9 ? please help me
0 new messages