Vbs Delete All Files In A Folder And Subfolders In Mail

Posted on by  admin

It is very frustrating seeing all these folders and sub-folders which I cannot delete or at least move to the delete folder. This is the first time I have installed Outlook myself, and the first time I pulled in emails from another message centre, so, with hindsight, of course, I would have gone about it very differently.

Learning has never been so easy!

Easy batch script to delete all files and subfolders in specific folder/drive. i.g If U want to delete all files and subfolders in d:temp catalog without deleting source (d:temp) catalog..

Instructions:
1. Copy and paste script to txt file (i.e. script.txt)
2. Follow instructions after REM comments
3.Change extension to .bat (ie. script.bat.) and run

REMEBER! FIRST TEST SCRIPT IN TESTING ENVIRONMENT

Vbs Delete All Files In A Folder And Subfolders In Mail Outlook

SCRIPT:

Vbs Delete All Files In A Folder And Subfolders In MailDelete any folder softwareVbs delete all files in a folder and subfolders in mail gmail

echo off

Vbs Delete All Files In A Folder And Subfolders In Mail Gmail

REM Edit your folder path
set CAT=d:temp

Cannot Delete Folder Windows

dir '%%CAT%%'/s/b/a sort /r >> %TEMP%files2del.txt
for /f 'delims=;' %%D in (%TEMP%files2del.txt) do (del /q '%%D' & rd '%%D')
del /q %TEMP%files2del.txt

Published: Sep 23, 2009 · Last Updated: Jun 17, 2011

7 Comments

  • Pure Capsaicin
    Martin9700 Sep 23, 2009 at 09:40am

    'Del *.* /s' will do the same thing... But I love the batch scripting!

  • Serrano
    Domin Sep 23, 2009 at 02:09pm

    Nope. 'Del *.* /s' will delete only files. You must use another command to delete empty folders.

  • Pure Capsaicin
    Martin9700 Sep 23, 2009 at 06:27pm

    My bad... I know it can be done... ah, here it is:

    RD /S /Q d:temp

  • Serrano
    Domin Sep 24, 2009 at 02:56am

    Handy switches, but deletes d:temp catalog :) .
    We can add MD command but what if catalolog is shared ?

  • Pure Capsaicin
    Martin9700 Sep 24, 2009 at 06:10am

    Net share to create shares and you can use CACLS to set NTFS permissions. But if you're clearing out a directory every night or whatever, I'd probably go with your script :)

    Should probably add the script to the Script Center too, even if someone doesn't use it in it's intended form it's a great example of the FOR command!

  • Serrano
    Domin Sep 24, 2009 at 06:37am

    Added to Script Center !

  • Poblano
    ksmedm Jan 8, 2015 at 11:56pm

    Thanks, we have this old application that every 5 minutes creates a folder and added a stamp .txt file that had results of the action.. after a few months it takes a while to delete the piles of directories... but this will keep it clean on a nightly script!

    Having the folder remain is critical to not having the reliant application from crashing. Thanks again!

Comments are closed.