Jay_ro Posted November 14, 2008 Share Posted November 14, 2008 Hello,I want to delete files and folders inside a folder, using command prompt, but I want to have a prompt with y/n for each folder to delete.The del /p command doesn't help me because it only deletes the files inside a folder. rd command is not helpful either because deletes all the folders inside my folder and it doesn't support a switch for prompting before delete.Do you guys know a command that can delete both files and folders in a directory with prompting? Or at least a command that deletes only folders, prompting me before?What do I need this for? I need it to delete some folders very fast. These folders inside my specific folder are very big, have lots of other files and sometimes prompts me to say that some files can't be deleted.....Thank you Link to comment Share on other sites More sharing options...
jaclaz Posted November 15, 2008 Share Posted November 15, 2008 What about a small batch file?If I get it right you want to delete files one by one, and then remove folders one by one, being prompted each time?jaclaz Link to comment Share on other sites More sharing options...
gunsmokingman Posted November 15, 2008 Share Posted November 15, 2008 This is a VBS script that should do what you want.Save As DelSubFolders.vbsDim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Dim Col, Obj, Folder'-> Set The Current Directory The Script Is In. '-> You Can Also Add A Direct Path To A FolderSet Folder = Fso.GetFolder(".")'-> Collect All The Sub Folders In The Folder For Each Col In Folder.SubFolders Obj = MsgBox("Did you want to delete this folder?" & vbCrLf & _ Col.Path, 4132,"Delete Folder")'-> If Yes Is Selected Then Delete The Folder If Obj = 6 Then Fso.DeleteFolder(Col.Path) Next Link to comment Share on other sites More sharing options...
Jay_ro Posted November 15, 2008 Author Share Posted November 15, 2008 What about a small batch file?If I get it right you want to delete files one by one, and then remove folders one by one, being prompted each time?jaclazI use this on multiple computers. A batch file will have top be carried on a flash, is not as useful as a command. Is there such a command at least for folder removal? Link to comment Share on other sites More sharing options...
jaclaz Posted November 15, 2008 Share Posted November 15, 2008 I use this on multiple computers. A batch file will have top be carried on a flash, is not as useful as a command. Is there such a command at least for folder removal?Well, you can memorize a "one line" batch, but still I am not sure if you want to check if folders are empty or not.I mean this, directly entered on command line:FOR /F "delims=" %A IN ('dir /b /s /A:D') DO ECHO "%A"will list only folders "below" current path, something like this:FOR /F "delims=" %A IN ('dir /b /s /A:D') DO RD "%A" 2>nulwill only delete EMPTY folders (without prompting)But you will have to re-run it for each "level".Using this:FOR /F "delims=" %A IN ('dir /b /s /A:D') DO RD "%A" /S 2>nulwill prompt you, but if you say yes to deleting a higher level folder, you will be prompted for all folders in the lower levels (that do not exist anymore)jaclaz Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now