Back on 2012 I had gotten some DOS help on another forum which is now inactive. I'm using a 2014 era, Win 7 Home Premium, 64-bit, computer. I have been using the batch file on a weekly basis since 2012 on various computers, and have converted well over 100,000 documents. But every time I set it up on a new computer, the computer needs some tweaks. It has been, now, 5 years since I tweaked a computer, and I'm having trouble tweaking my own
The purpose of the script is to take a list of image files with odd extensions, concatenate them by file name and page number, and produce a PDF file for each collection of images into a properly named file. Source file names look like this, 00254567.001, 00254567.002, etc. for the document numbered 00254567 going page by page by extension. The destination file name looks like this, 00254567.pdf. The next document would be 00254568.001 etc. The image files seem to be in the TIFF format.
To prepare to run this on my computer I have
- downloaded and installed the GnuWin32 install package titled tiff-3.8.2-1.exe.
- taken the folders found in the GnuWin folder and dropped them all into c:\bin so this script will pick them up,
- created c:\test\src and c:\test\dest folders, and
- seeded c:\test\src with a 5-page document and a 6-page document to run the test.
Code: Select all
@echo off & setlocal EnableExtensions ENableDelayedExpansion set oldpath=%PATH% set PATH=%PATH%;c:\bin; ::Following sets source and destination folders, ::normally the source would be on the CD (d:\folder name) ::normally destination would be a server set SRC=c:\test\src set DST=C:\test\dest :: This turns on ECHO for debugging. set DBG=ECHO/ ::Following turns off the ECHO function ::set "DBG=" ::Following points the batch at the source directory pushd %SRC% ::Following finds files with leading zeros and extension .001 ::Then it strips off the leading zeros ::Strip zeros in directory /B simplifies file attributes ::/A-D shows all files but not directories ::-D removes directory names from file list ::/ONE sorts list by name and then file extension ::Two % signs are used because this is a batch file. for /F "tokens=*" %%A in ('dir /B/A-D/ONE "*.001"') do ( ::Following sets PG (page number?) to null set "PG=" ::Following collects image files with the ::same name and different numbered extensions :: for /F "tokens=*" %%B in ('dir /B/A-D/ONE "%%~nA.0*"') do ::Set PG to contain multiple file names, not just one set PG=!PG! %%~nxB ::Following converts collected files into one .tif file tiffcp -c lzw !PG! %DST%%%~nA.TIF ::Following changes the .tiff file into a PDF ::inside the destination folder tiff2pdf -o %DST%%%~nA.PDF %DST%%%~nA.TIF ::Following deletes the single TIF file DEL %DST%%%~nA.TIF ) POPD set PATH=%oldpath%
Again, I have gotten this running on many computers since 2012. What I don't remember is whether I have had to tweak the batch file to make it run. I do have to change the source and destination folders for each computer and setup, but that's straightforward.
When I run the batch I see the CMD window open and immediately close. In the past I have solved this by making sure all the converter executables are inside the c:\bin folder. Unless I missed something, that is done on this computer, and I have rebooted. Normally what I see when I run the batch is the CMD window opens and shows progress in the form of a document by document ECHO of the progress interspersed with a TIFF conversion error message for every single document. I have ignored the error messages because the PDF documents come through the process just fine.
What am I missing?