Solved Rotate Files

September 13, 2011 at 17:01:46
Specs: Windows Server 2003
I am trying to write a script that will delete all files in a folder called level 4 and then copy any files in the level 3 folder to level 4, then copy any files in the level 2 folder to level 3, then copy any files in the level 1 folder to level 2 and then copy any files *.iis to the Level 1 folder.

This is what I have wrote so far but i cant get it to work.

cd "C:\Program Files\Microsoft ISA Server\ISALogs\Level 4"
echo y | Del *.*
cd "C:\Program Files\Microsoft ISA Server\ISALogs"
move "Level 3\*" "Level 4"
move "Level 2\*" "Level 3"
move "Level 1\*" "Level 2"
xcopy "C:\Program Files\Microsoft ISA Server\ISALogs\*.iis" "C:\Program Files\Microsoft ISA Server\ISALogs\Level 1"


See More: Rotate Files

Report •


#1
September 13, 2011 at 17:58:49
✔ Best Answer
If the above worked, the following would probably be faster:
cd /d "C:\Program Files\Microsoft ISA Server\ISALogs"
rd /s /q "Level 4"
move "Level 3" "Level 4"
move "Level 2" "Level 3"
move "Level 1" "Level 2"
copy *.iis "Level 1"

That said . . .

cant get it to work.
it doesn't work how?

How To Ask Questions The Smart Way


Report •

#2
September 13, 2011 at 21:13:33
Thanks Razor2.3, Your way almost works perfectly, since its renaming the folders I need to remake the directory which is fine. The main problem it is making all the .iis files a single file called Level 1 instead of copying them into a folder called Level 1.

Report •

#3
September 14, 2011 at 11:54:46
Before you copy the files into "Level 1", add the following line:
md "Level 1"

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
September 14, 2011 at 16:23:41
Thanks Razor2.3, this is now solved.

Final script

cd /d "C:\Program Files\Microsoft ISA Server\ISALogs"
rd /s /q "Level 4"
move "Level 3" "Level 4"
move "Level 2" "Level 3"
move "Level 1" "Level 2"
md "Level 1"
copy *.iis "Level 1"


Report •


Ask Question