Solved

Need help writing batch file.

Posted on 2003-11-21
3
452 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 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Print Server: How to Create it? 1 774
Windows 2000 Server to 2008 upgrade 8 526
Windows 2000, Ghost 2003, disk1 disk 2 mirroring 17 371
windows 2000 image 3 148
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…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

756 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