LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete folder in a particular scenario using batch file

How to achieve this using a batch file?

 

The batch file should check if inside this folder "c:\test\", a directory named "temp1" only is present. If so then delete the folder test, but if the folder test contains more directories and files other than "temp1" directory, then just remove the "temp1" directory alone.

 

Regards,

Mathan

0 Kudos
Message 1 of 2
(2,587 Views)

First, why are you asking about this in a LabVIEW forum? I would suggest starting with Google.

Second, you could simplify your algorithm by deleting temp1 and then checking if the test dir is empty or not. The Windows command is rd, if memory serves, but I believe that doesn't work on non-empty directories, so you might need to add switches to it or use another command. You could probably even simplify it by trying to delete test and letting it fail, so something like this:

 

del c:\test\temp1\*.* (add switch for quiet mode).

rd c:\test\temp1 (and check if there is a recursive switch)

rd c:\test (should fail if not empty).


___________________
Try to take over the world!
0 Kudos
Message 2 of 2
(2,573 Views)