Computer Hope

Microsoft => Microsoft DOS => Topic started by: jake74 on September 01, 2005, 12:23:47 PM

Title: For loop with xcopy
Post by: jake74 on September 01, 2005, 12:23:47 PM
I've got a directory with sub directories like this:
--1001
   --1001
      -----Bunches of files and dirs
--1002
  --1002
      -----Bunches of files and dirs
I want to move the contents of sub-directory 1002 up one level, then delete the 1002 sub-directory folder.

Here's what I'm trying to do (pseudo code)

for each %var% in <dir /B /A:D> (or a text file with these dir's listed){
   xcopy %var\%var %var /s /e
   del %var/%var/*
}

This is the command that works:
xcopy 7614\7614 7614 /s /ce
The delete didn't work.  

Your help is much appreciated.

Jake B
Title: Re: For loop with xcopy
Post by: earie on September 08, 2005, 05:47:59 AM
Try using:

del /q %var%\%var%
rd /q %var%\%var%


Or better yet (delede the whole folder and content together):
rd /q /s %var%\%var%

Good luck
Title: Re: For loop with xcopy
Post by: jake74 on September 08, 2005, 11:25:24 AM
Thanks!