943,532 Members | Top Members by Rank

Ad:
Dec 16th, 2008
0

Using Pipe in to rmdir command

Expand Post »
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
Reputation Points: 64
Solved Threads: 7
Junior Poster
shouvik.d is offline Offline
198 posts
since Jan 2007
Dec 17th, 2008
1

Re: Using Pipe in to rmdir command

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
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007
Dec 17th, 2008
0

Re: Using Pipe in to rmdir command

Hi Eggi,

Problem Solved.....Dude you are genius . See you around
Reputation Points: 64
Solved Threads: 7
Junior Poster
shouvik.d is offline Offline
198 posts
since Jan 2007
Dec 17th, 2008
0

Re: Using Pipe in to rmdir command

Cool... and thanks

Glad you're doing good!

, Mike
Reputation Points: 102
Solved Threads: 47
Posting Whiz
eggi is offline Offline
399 posts
since Oct 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: Random Number Korn
Next Thread in Shell Scripting Forum Timeline: script to find function names





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC