Solved

Need help writing batch file.

Posted on 2003-11-21
3
418 Views
Last Modified: 2010-04-14
Can somebody help me with some sample code to do the following.

go into every subfolder on a given drive (lets say Z)

Deltree the temp folder

Recreate the temp folder

copy a file into the newley created temp folder

Thanks in advance
0
Comment
Question by:SPittwood
3 Comments
 
LVL 16

Accepted Solution

by:
_nn_ earned 125 total points
ID: 9796604
Following should work I think :

@echo off
set BASEPATH=Z:
set TEMPNAME=temp
set NEWFILE=X:\full\path\to\the\new\file.ext

pushd %BASEPATH%
for /R %%a in (.) do if exist "%%a\%TEMPNAME%" call :do_it "%%a"
popd
goto end

:do_it
rd /s /q "%~1\%TEMPNAME%"
md "%~1\%TEMPNAME%"
copy %NEWFILE% "%~1\%TEMPNAME%"

:end
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Is your company's data protection keeping pace with virtualization? Here are 7 dynamic ways to adapt to rapid breakthroughs in technology.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now