tags:

views:

41

answers:

1

i want to delete sub folder and item in sub folder

for example i have f:\ComSvr01\Trend(month_09.10 , month_08.10 ,...)\t1.trd

i want to delete all folder month_mm.yy

and item in folder but remain folder name Trend (f:\ComSvr01\Trend)

How to do?

help me please

A: 

Assuming f:\ComSvr01\Trend(month_09.10 , month_08.10 ,...)\t1.trd means

f:\ComSvr01\Trend\month_09.10\...
f:\ComSvr01\Trend\month_08.10\...
.
.
.

use this inside a batch file. You must have %%f and not %f inside the batch file

for /f "tokens=*" %%f in ('dir f:\ComSvr01\Trend /ad/b') do rd /s/q f:\ComSvr01\Trend\%%f

From the command line you use only use %f

for /f "tokens=*" %f in ('dir f:\ComSvr01\Trend /ad/b') do rd /s/q f:\ComSvr01\Trend\%f
Preet Sangha
i using the following command "tokens=*" %%f in ('dir f:\ComSvr01\Trend /ad/b') do rd /s/q f:\ComSvr01\Trend\%%f but i get %%f was unexpected at this time why? please.. i'm rookie ,i don't understand this command
Fernatit
thank you very much. i use that command in cmd can work well , but when i create file .bat and double click at icon the result is can't work. Not happen, sub folder and item are remains. i don't know why. what i should to do?
Fernatit
open a command window and run the batch file from the command line - what does it say?
Preet Sangha
i mean when i type your command on command window and press Enter(for test) the result is ok, but when i create batch file from that your command and double click on batch icon. I find that nothing happens,all file are remains. sorry i can't speak english well, help me Please.
Fernatit
ok inside the batch file please use the first command. You need to have %%f and not just %f.
Preet Sangha
oh I am wrong. thank you very very much :-) for command and advice.
Fernatit
you're welcome.
Preet Sangha
It should be about current directory. wasn't that?
Dr TJ