Solved

batch file find, rename, move, convert to pdf

Posted on 2010-09-10
8
590 Views
Last Modified: 2012-05-10
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...???

0
Comment
Question by:KLLtar
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 40

Expert Comment

by:RQuadling
ID: 33647402
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?
0
 

Author Comment

by:KLLtar
ID: 33649491
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!
0
 
LVL 6

Expert Comment

by:judgeking
ID: 33655834
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'
0
 
LVL 11

Expert Comment

by:Ben Personick
ID: 33669370
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

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:KLLtar
ID: 33671845
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?
0
 
LVL 40

Expert Comment

by:RQuadling
ID: 33671999
That is a .BAT file.
0
 
LVL 11

Accepted Solution

by:
Ben Personick earned 500 total points
ID: 33672197
The "code" is "windows commandline" aka "batch" aka "bat" and will run on windows XP.  Just copy the 'code' and save it as say "MovePDF.bat" then open that file in Notepad++ or whatever text editor you more prefer and edit the variabls at the top to hold values appropriate for your environment.

Please Note:  It is Always good practice to test a script before you run it on production data -- There may be syntax issues (a forgotten quote or parentethis or the ilk) because I did not test run the script.  Please make your own test folder with your own documents and report back any errors.
0
 
LVL 11

Expert Comment

by:Ben Personick
ID: 33810454
Hey, thanks for the points! ^^

~Q
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now