Computer Hope

Microsoft => Microsoft DOS => Topic started by: x3g on February 24, 2009, 12:20:15 PM

Title: Help with search
Post by: x3g on February 24, 2009, 12:20:15 PM
hello all,
I need to search c:\program files and sub folders for a specific file and if it's found copy it to a specific folder.
Thanks in advance.
Title: Re: Help with search
Post by: Dias de verano on February 24, 2009, 12:27:58 PM
Sounds like homework.
Title: Re: Help with search
Post by: x3g on February 24, 2009, 12:33:52 PM
no it isn't homework but thanks for your quick reply.
We have a program it is called Imagenow that has an issue with Acrobat reader 9. When Imagenow crashes on a box that runs Acrobat 9 I need to find 2 files, ace.dll and agm.dll and copy them to the imagenow folder. This issue is widespread and I would like to have a batch file to run everytime this issue comes up.
Title: Re: Help with search
Post by: Dias de verano on February 24, 2009, 01:02:20 PM
1. What is the full path of the Imagenow folder?
2. What do you want to happen if either of the files is not found?
Title: Re: Help with search
Post by: x3g on February 24, 2009, 01:34:12 PM
the imagenow location is known
c:\program files\imagenow6
but i want to have it search at least c:\pf\adobe and all the sub folders for ace.dll and agm.dll
The program can just exit if no files are found.
Title: Re: Help with search
Post by: Dias de verano on February 24, 2009, 01:47:16 PM
So you want to search the folder tree below C:\Program Files\Adobe for ace.dll and agm.dll, and if they are found, copy them to the folder C:\Program Files\imagenow6

I am presuming you are using an NT family OS, i.e. Windows 2000, XP, Vista, etc.

This batch code will search for those two files and copy the first ones it finds into the imagenow6 folder, overwriting any that may be there already.

I expect you can see where to modify the search path.

Try this...

Code: [Select]
@echo off
cd /d "C:\Program Files\Adobe"
dir /s "ace.dll" || goto skipace
for /f "delims==" %%A in ('dir /s /b ace.dll') do copy /Y "%%~dpnxA" "C:\Program Files\imagenow6"
:skipace
echo ace.dll not found
dir /s "agm.dll" || goto skipagm
for /f "delims==" %%A in ('dir /s /b agm.dll') do copy /Y "%%~dpnxA" "C:\Program Files\imagenow6"
:skipagm
echo agm.dll not found
Title: Re: Help with search
Post by: x3g on February 24, 2009, 01:54:43 PM
just what I needed. Thank you very much for your prompt assistance.