Link to home
Start Free TrialLog in
Avatar of KLLtar
KLLtarFlag for United States of America

asked on

batch file find, rename, move, convert to pdf

I've been given the task to query for files across various network drives, rename them, move them into different directories, and then convert them to pdf files.

Any ideas, suggestions, strategies, software...???

Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

What type of files?

I use Imagick's CONVERT (http://www.imagemagick.org/script/index.php) to process TIFF/JPG/faxes/etc files into PDFs.

As for scanning across the drives, you would need to have a list of drives and possible file types.

Is this a one of task, or something you are going to run on a regular basis?
Avatar of KLLtar

ASKER

The files are a mixed breed - .xls, .doc, .pdf, .jpg, ppt,....

Right now, we're quering network drives and finding matches based on known keywords, but when we find them, we need to move them into a different directory, batch rename them (like projectName), and then convert them into pdf files.

We have over 11,000 files to processs.

Hopefully, this is a one time job!
I use Win2PDF (www.win2pdf.com).  Basically it's installed as a printer, but creates PDF documents.  They also have a product (http://www.win2pdf.com/products/products.htm) called Batch2PDF that 'converts entire directories of .doc, .html, .txt and .rtf files to PDF files'
Avatar of Ben Personick (Previously QCubed)
I believe you are looking for something along these lines, perhaps this exactly.  (Please see the attached script.)

NOTE:  I am using PDF Creator simply because it is free and because it is installed on all of my machines by default, and therefore I am somewhat familliar witht eh syntx.  If you have a different PDF Creation mechanism you would prefer to use simply substitute it's commands as necessary.
You can Download PDF Creator here for free:  HTTP://Sourceforge.net/Projects/PDFCreator/

@ECHO OFF
SET RemotePathList="\\Nas1\share1\Folder", "\\Nas1\share2\Folder", "\\Nas2\share1\Folder"
SET "FileMask=*.xls"
SET "ProjectName=ProjectX"
SET "ProjectPath=\\Nas3\Share4\Folder Five\ProjectX Folder"
SET "PDFCreatorPath=C:\Program Files\PDFCreator\PDFCreator.exe"

::Finds Files, Copies them to the project directory and int he process renames them.
FOR %%L IN (%RemotePathList%) DO FORFILES /P "%%L" /S /M %FileMask% /C "cmd /c COPY /Z "@Path\@File" "%ProjectPath%\ProjectName_@File""
:: Note in the above statement we don;t trap errors, they will echo to the command prompt for now.

:: Here we convert the renamed files to PDF and delete the files we copied int he last step
FOR /F "Tokens=1-2 del%%P IN ('DIR /A:-D /B "%ProjectPath%" ') DO "%PDFCreatorPath%" /PF"%ProjectPath%\%%P" && DEL /F /Q "%ProjectPath%\%%P"
:: Note in the above statement we don't trap errors, they will echo to the command for now; and if a file is NOT converted it should not be deleted.

Open in new window

Avatar of KLLtar

ASKER

QCubed,

What language is the code written in? Does in run in WIn XP environment?
If so, do I just save the code in a file with a .bat extension and then run it from the command line?
That is a .BAT file.
ASKER CERTIFIED SOLUTION
Avatar of Ben Personick (Previously QCubed)
Ben Personick (Previously QCubed)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey, thanks for the points! ^^

~Q