Copying a file to folders found based on a search (MS-DOS)

December 20, 2011 at 03:22:00
Specs: Windows XP
I'm just wondering if anybody could help me out here. I've been trying to work this out for the last day!
Basically, I need to copy a file "LogMeIn.url" which is currently on the desktop to the Quick Launch toolbar for All Users using a batch file.
There is no Quick Launch folder in All Users and by the looks of it there is no easy way of doing it.
Therefore, I've created a batch file which at the moment finds all the folders with "Quick Search in the title.
Currently the code is:

cd \
dir /ad /b /s | findstr "\<Launch\>"

However I was wondering if once you have obtained the search results whether there is a way of then copying a file to each of folders that have been found in the search results?

If you guys have any thoughts about this or if there is a much easier way of doing this please give me a shout. I will be extremely grateful :D !

See More: Copying a file to folders found based on a search (MS-DOS)

Report •

December 22, 2011 at 12:35:25
Hello PaulioH,

Yes there is a way to loop through the results and perform an action or actions on each line.

First you would need to output the results of your dir to a file with:

cd \
dir /ad /b /s | findstr "\<Launch\>" > output.tmp

REM Then use a for loop to loop through those results and copy to each of them

for /f %%a in (output.tmp) do (
copy c:\path\to\desktop\logmein.url %%a

Report •
Related Solutions

Ask Question