| 1. |
Solve : Piping Question ...? |
|
Answer» Hello all, Could anyone please shed some light as to why none of the following work (xp prompt), its fairly obvious what I am trying to achieve ... So, I assumed wrong. But, to answer your question. Quote from: RD Help C:\>rd /? Note the singluar 'directory' etc. This means that piping or by other means giving a list of directories to the rd command will NOT work. It requires a directory name. Also, if you want * a wildcard to work I think you have to use the 'del' command. Code: (this would grab a directory name from a file and use it) [Select]@set dirname=<dirtodelete.txt @rd /s /q %dirname% NOTE: That will only work for one directory in the file. Pretty pointless but it wouldn't work the other way.Thank you again DeltaSlaya ... however, what I dont understand is that if rd is only supposed to work with a single directory, then why does this code work as expected ... md moo cow duck rd moo cow duck You see what I mean?Good point. Looking over it again i see how that could work. But the two original methods you supplied will not work. Perhaps a for statement could perform it with multiple directories as well. To use a file with a list of directories on each line, or on the same with a space on each this should work. Code: [Select]for /F "delims=" %%i in ('findstr . dirstodel.txt') do rd /s /q %%i I'm learning for statements myself, but that should work with a file full of directories.This may explain better, but remember I'm not a DOS command expert: Code: [Select]@echo off :: Create txt file with list of dirs echo Testfolder1 Testfolder2 Testfolder3 Testfolder4 Testfolder5>todel.txt :: Assign var with contents set /p d=<todel.txt :: Make directories mkdir %d% :: So you can check they were made echo Any key. pause >nul :: Delete with FOR for /F "delims=" %%i in ('findstr . todel.txt') do rd /s /q %%i ::Finished echo. echo Done. ping -n 3 LOCALHOST >nulOk I will look over that! Thanks for your help! TOP man! |
|