Solved

Need help writing batch file.

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Migrate DFS role 3 866
Group Policy 9 562
WMI Uptime Script Reporting Incorrect Number on W2k Server 16 795
Kill system process in windows 2000 10 216
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…
Changing a few Outlook Options can help keep you organized!
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

737 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