How long are the paths?

There are other ways to handle this, btw...

Try the following snippet.  It should handle long folders even if Windows
complains about them

@echo off
 SETLOCAL ENABLEDELAYEDEXPANSION
 SET @SOURCE=%SystemDrive%
 SET @DEST=D:\SomePlace
 SET @FIND=PrivacIE

:Main
 for /f "tokens=*" %%v in ('dir /ad /b /s "%@SOURCE%\*.*" 2^>NUL ^| FIND /I
"%@FIND%"') do (
   SET @DIR=%%~fpv
   ECHO.
   ECHO SOURCE: !@DIR!
   ECHO   DEST: %@DEST%\%%~pv
   PUSHD !@DIR!
   echo XCOPY *.* "%@DEST%%%~pv" /S /E /R /Y
   ECHO.
   POPD
 )


:ExitBatch
 ENDLOCAL





* *

*ASB* *http://about.me/Andrew.S.Baker* *Harnessing the Advantages of
Technology for the SMB market…

*



On Wed, Jul 20, 2011 at 2:24 PM, Jeff Bunting <bunting.j...@gmail.com>wrote:

> Thanks all.  Scott's suggestion is close and at least got me pointed in the
> right direction.  Some of the paths are too long for DIR which throws a
> wrench in the works, so I'm going to have to rely on windows search for now.
>
> Powershell, unfortunately, currently isn't an option.
>
> Jeff
> On Wed, Jul 20, 2011 at 12:23 PM, Andrew S. Baker <asbz...@gmail.com>wrote:
>
>> Good one, Scott.
>>
>> Jeff, remember to add a % to each variable if used in a batch file, vs the
>> command line.
>>
>>
>>
>> * *
>>
>> *ASB* *http://about.me/Andrew.S.Baker* *Harnessing the Advantages of
>> Technology for the SMB market…
>>
>> *
>>
>>
>>
>> On Wed, Jul 20, 2011 at 12:13 PM, Crawford, Scott 
>> <crawfo...@evangel.edu>wrote:
>>
>>>  For /f “tokens=*” %i in (‘dir *WORDS_TO_SEARCH* /s/a/b/ad’) do robocopy
>>> /mir “%i” DESTINATION_PATH****
>>>
>>> ** **
>>>
>>> This will search a folder tree for directorys.  Change the dir command to
>>> eliminate the /s if you only want to search the root.****
>>>
>>> ** **
>>>
>>> *From:* Jeff Bunting [mailto:bunting.j...@gmail.com]
>>> *Sent:* Wednesday, July 20, 2011 11:01 AM
>>>
>>> *To:* NT System Admin Issues
>>> *Subject:* file searching and copying****
>>>
>>> ** **
>>>
>>> I'm attempting to search for particular words in a directory name (must
>>> use wildcards!), and, if found, copy the the directory tree while
>>> maintaining its structure to another directory.****
>>>
>>>  ****
>>>
>>> Are there any native tools (or reskit like robocopy) that can accomplish
>>> this somewhat easily?  ****
>>>
>>>  ****
>>>
>>> thanks,****
>>>
>>> Jeff****
>>>
>>>
>>> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
>> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>>
>> ---
>> To manage subscriptions click here:
>> http://lyris.sunbelt-software.com/read/my_forums/
>> or send an email to listmana...@lyris.sunbeltsoftware.com
>> with the body: unsubscribe ntsysadmin
>>
>
> ~ Finally, powerful endpoint security that ISN'T a resource hog! ~
> ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~
>
> ---
> To manage subscriptions click here:
> http://lyris.sunbelt-software.com/read/my_forums/
> or send an email to listmana...@lyris.sunbeltsoftware.com
> with the body: unsubscribe ntsysadmin
>

~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to listmana...@lyris.sunbeltsoftware.com
with the body: unsubscribe ntsysadmin

Reply via email to