Computing.Net > Forums > Programming > Batch script to search/copy/replace

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Batch script to search/copy/replace

Reply to Message Icon

Name: ckltd740
Date: July 8, 2008 at 17:31:03 Pacific
OS: Windows XP
CPU/Ram: NA
Product: Dell/D630
Comment:

All,
I'm looking for assistance with putting together a batch file to be loaded at logon or system startup that will:

1)Search the local C drive for an exact file path/folder
2) Write the search results to a log file to review both successful and unsuccessful hits by PC hostname
3) Terminate when search is unsuccessful, but continue for successful hits
4) Copy/Move folder contents to a backup folder
5) Copy another set of files to the target folder to replace previous files

I need this script to execute ONLY for successful search hits. I plan to use Active Directory Services for Windows Server 2003 to push this batch file out to an OU containing Windows 2000/XP target machines.

Any leads or ideas would be most appreciated. Thanks.

ckltd740



Sponsored Link
Ads by Google

Response Number 1
Name: ckltd740
Date: July 8, 2008 at 19:39:40 Pacific
Reply:

I did find a post similar to what I need, but need to find a way to prefix that script with the required local C drive search string and logfile update I need. Post I'm referencing is titled "batch file to copy and move certain" on this site.

ckltd740


0

Response Number 2
Name: Mechanix2Go
Date: July 8, 2008 at 22:48:41 Pacific
Reply:

@echo off
setLocal EnableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/s/b/a-d c:\somefile') do (
if errorlevel 1 goto :eof
echo move %%a c:\bakup
echo copy c:\newstuff %%~Pa
)


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 3
Name: ckltd740
Date: July 9, 2008 at 09:12:51 Pacific
Reply:

Thanx M2Go. This looks good; we'll give it a go and check the result.

ckltd740


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Batch script to search/copy/replace

Batch to search all drives and copy newest www.computing.net/answers/programming/batch-to-search-all-drives-and-copy-newest/20316.html

Batch code to search for new files www.computing.net/answers/programming/batch-code-to-search-for-new-files/16459.html

batch script to upload to ftp www.computing.net/answers/programming/batch-script-to-upload-to-ftp/16987.html