[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Need help writing batch file.

Posted on 2003-11-21
3
Medium Priority
?
470 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

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…
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

650 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