?
Solved

Need help writing batch file.

Posted on 2003-11-21
3
Medium Priority
?
467 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Accepted Solution

by:
_nn_ earned 375 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

770 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