Solved

batch file find, rename, move, convert to pdf

Posted on 2010-09-10
8
606 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:Richard Quadling
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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 11
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
 

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:Richard Quadling
ID: 33671999
That is a .BAT file.
0
 
LVL 11

Accepted Solution

by:
Ben Personick (Previously QCubed) 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
ID: 33810454
Hey, thanks for the points! ^^

~Q
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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