Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

batch file find, rename, move, convert to pdf

Posted on 2010-09-10
8
Medium Priority
?
617 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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

Accepted Solution

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

~Q
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

647 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