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.
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
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
)
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
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.
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
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).
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
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.
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
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
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!
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.
> >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.
Hmmm. Are you pulling our legs? :) I tried that and only the first
image displayed.
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>)