Link to home
Start Free TrialLog in
Avatar of tkthelpdesk
tkthelpdeskFlag for United States of America

asked on

Need a script or batch file to move PDF files

I have thousand of PDF files in a folder, I know of a few hundred I need, I need a script where I can tell the script what .pdf files I need form the folder and it will dump them to a separate folder.
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

What are the criteria for selection?
Need specific detail. What filename patterns or dates, if any?
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

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
Avatar of tkthelpdesk

ASKER

The files are all named with the same pattern of which is a date followed by an underscore and then a number: Example 01232014_12345678.pdf    some numbers are longer such as 01232014_123456789.pdf and some shorter such as 01232014_12345.pdf

I have a list of certain ones I need to pull out and drop in a separate folder but I am not so fortunate that they would be sequential. It would take me days to pluck them one by one
Just rename your list file to select.txt, as shown by Bill, on line 4

Make sure your list has just the file names without the folder prefixes.
A simplified version of Bill's:

@echo off
setlocal EnableDelayedExpansion

set SelectFile=select.txt
set BaseDir=B:\EE\EE28930873\from
set DestDir=B:\EE\EE28930873\to

for /f "usebackq tokens=*" %%A in ("%SelectFile%") do if exist "%%A" ECHO copy "%BaseDir%\%%A" "%DestDir%"

Open in new window