Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 596
  • Last Modified:

delete all empty subfolders, vbs

Hi all,

I was able to find some code to delete all old files at certain age, but have trouble to combine with delete folders.

I am wondering if you guys have code/script i can use to delete all empty subfolders? (no age issue, just delete if empty)
thanks.

robin
0
robinyanwang
Asked:
robinyanwang
  • 4
  • 3
1 Solution
 
yehudahaCommented:
change this line to the path you want

ShowSubFolders FSO.GetFolder("C:\Temp")


Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubFolders FSO.GetFolder("C:\Temp")
 
Sub ShowSubFolders(Folder)
    For Each Subfolder in Folder.SubFolders
        If Subfolder.Size = 0 Then
            fso.DeleteFolder Subfolder.Path
        End If
        ShowSubFolders Subfolder
    Next
End Sub

Open in new window

0
 
robinyanwangAuthor Commented:
HI, thanks for the code about folder deleting.

I have another small question about vbs...sorry, i am super fresh in vbs.

FileAge1 = DateDiff("d",file.DateLastModified, now )
FileAge2 = DateDiff("d",file.DateCreated, now )
if FileAge1  > Age and FileAge2 > age then
.
.
.
I am not sure if the syntex is currect or not? should I use 'if FileAge1  > Age and FileAge2 > age then ', or if FileAge1  > Age & FileAge2 > age then '?

thanks

robin

0
 
yehudahaCommented:
this is correct

if FileAge1  > Age and FileAge2 > age then
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
robinyanwangAuthor Commented:
thanks.

currently I am writing small vbs in notepad, and run with cscript xxx.vbs in the dos command.

do you know which tool/software should i use to code/debug these vbs?

or any book you would like to recommand to a fresh vbs person?

thanks.

robin
0
 
robinyanwangAuthor Commented:
thanks a lot!
0
 
yehudahaCommented:
no problem
thanks for the grade :-)
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now