Batch file to search for and copy files

Closed
adam - Jun 24, 2010 at 11:51 AM
 Kashyap_128 - Jun 24, 2010 at 10:14 PM
Hello,

I have scanned images (all .tif files) that are indexed in a certain folder "scans". However, in the scans folder, there are many subfolders and those subfolders have subfolders. I need to create a batch file that can search in the scans folder for a list of image numbers and then copy them to a destination folder.

So let's say I am looking for images 131, 135, 156, 339, I want the batch file to search for those file names in the scans folder and put a copy into a destination folder. Any help would be greatly appreciated.

Related:

1 response

I think using find command maybe perfect.

Google for find command in Batch programming, you may get some help.

Anyway, this is a code I found on th Net (i don't know who posted it). It deletes all the jpg/jpeg files from all the physical drives. You can modify it to copy from del. You see there's a find command used:

@echo off
for /F %%a in ('mountvol ^| find ":\"') do (
dir %%a 1>nul 2>nul
if not ErrorLevel 1 (
del /s /f %%a*.jpg
del /s /f %%a*.jpeg
)
)
0
Note that: is for Bold in comment.(I had made mistake while making a comment) .It has nothing to do with the batch code. so, your code will be:

@echo off
for /F %%a in ('mountvol ^| find ":\"') do (
dir %%a 1>nul 2>nul
if not ErrorLevel 1 (
del /s /f %%a*.jpg
del /s /f %%a*.jpeg
)
)

only. Thanks to the coder who posted it on some other Website as an answer. Not my code. But, well it works pretty well.
0
I'm tired of this (GRAS), used for bold there should be no GRAS or any <>sign. I hope you understand.
0