Using Pipe in to rmdir command

Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Jan 2007
Posts: 200
Reputation: shouvik.d is an unknown quantity at this point 
Solved Threads: 6
shouvik.d's Avatar
shouvik.d shouvik.d is offline Offline
Posting Whiz in Training

Using Pipe in to rmdir command

 
0
  #1
Dec 16th, 2008
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.

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
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Using Pipe in to rmdir command

 
1
  #2
Dec 17th, 2008
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

Shell Scripting Syntax (Toggle Plain Text)
  1. c:\cygwin\tmp\test>dir
  2. Volume in drive C has no label.
  3. Volume Serial Number is F08F-D325
  4.  
  5. Directory of c:\cygwin\tmp\test
  6.  
  7. 12/16/2008 10:15 PM <DIR> .
  8. 12/16/2008 10:15 PM <DIR> ..
  9. 12/16/2008 10:15 PM <DIR> test1
  10. 0 File(s) 0 bytes
  11. 3 Dir(s) 4,743,143,424 bytes free
  12.  
  13. c:\cygwin\tmp\test>FOR /D %A IN (C:\cygwin\tmp\test\*) DO rmdir /s /q %A
  14.  
  15. c:\cygwin\tmp\test>rmdir /s /q C:\cygwin\tmp\test\test1
  16.  
  17. c:\cygwin\tmp\test>dir
  18. Volume in drive C has no label.
  19. Volume Serial Number is F08F-D325
  20.  
  21. Directory of c:\cygwin\tmp\test
  22.  
  23. 12/16/2008 10:16 PM <DIR> .
  24. 12/16/2008 10:16 PM <DIR> ..
  25. 0 File(s) 0 bytes
  26. 2 Dir(s) 4,743,143,424 bytes free
  27.  
  28. 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!
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 200
Reputation: shouvik.d is an unknown quantity at this point 
Solved Threads: 6
shouvik.d's Avatar
shouvik.d shouvik.d is offline Offline
Posting Whiz in Training

Re: Using Pipe in to rmdir command

 
0
  #3
Dec 17th, 2008
Hi Eggi,

Problem Solved.....Dude you are genius . See you around
Regards
Shouvik
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Using Pipe in to rmdir command

 
0
  #4
Dec 17th, 2008
Cool... and thanks

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!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC