| | |
Using Pipe in to rmdir command
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
Hi,
I am using a scheduled task that runs every night to take backup of important files. This task creates a folder in the following format
Backup_DD_MM_YY
where DD_MM_YY denotes the date when the backup was taken.
Now everytime this scheduler runs I need to remove the older directory and create a new one with current date. In order to remove the directory I tried the following but it doesn't work.
Can somebody please help
I am using a scheduled task that runs every night to take backup of important files. This task creates a folder in the following format
Backup_DD_MM_YY
where DD_MM_YY denotes the date when the backup was taken.
Now everytime this scheduler runs I need to remove the older directory and create a new one with current date. In order to remove the directory I tried the following but it doesn't work.
for %%A in (C:\Backup*) do rmdir /s /q %%A Can somebody please help
Last edited by shouvik.d; Dec 16th, 2008 at 2:17 am. Reason: used Inline Code
Regards
Shouvik
Shouvik
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Hey There,
Unless it's a permissions issue (where you can't delete the folders as the user that runs the batch file) is it possible that you're trying this at the command line as proof-of-concept for the batch file.
If you're doing command line testing, although the variable MUST be %%A in your batch file, it has to be %A when run from the command line (why? I haven no idea
Best wishes,
Mike
Unless it's a permissions issue (where you can't delete the folders as the user that runs the batch file) is it possible that you're trying this at the command line as proof-of-concept for the batch file.
If you're doing command line testing, although the variable MUST be %%A in your batch file, it has to be %A when run from the command line (why? I haven no idea

Shell Scripting Syntax (Toggle Plain Text)
c:\cygwin\tmp\test>dir Volume in drive C has no label. Volume Serial Number is F08F-D325 Directory of c:\cygwin\tmp\test 12/16/2008 10:15 PM <DIR> . 12/16/2008 10:15 PM <DIR> .. 12/16/2008 10:15 PM <DIR> test1 0 File(s) 0 bytes 3 Dir(s) 4,743,143,424 bytes free c:\cygwin\tmp\test>FOR /D %A IN (C:\cygwin\tmp\test\*) DO rmdir /s /q %A c:\cygwin\tmp\test>rmdir /s /q C:\cygwin\tmp\test\test1 c:\cygwin\tmp\test>dir Volume in drive C has no label. Volume Serial Number is F08F-D325 Directory of c:\cygwin\tmp\test 12/16/2008 10:16 PM <DIR> . 12/16/2008 10:16 PM <DIR> .. 0 File(s) 0 bytes 2 Dir(s) 4,743,143,424 bytes free c:\cygwin\tmp\test>
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Cool... and thanks 
Glad you're doing good!
, Mike

Glad you're doing good!
, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
![]() |
Other Threads in the Shell Scripting Forum
- Previous Thread: Random Number Korn
- Next Thread: script to find function names
| Thread Tools | Search this Thread |





