Re: Scripts that delete files, not folders.
- From: "DallasITguy" <DallasITguy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 16 Jul 2005 08:05:02 -0700
Thank you very much. One fix and one problem for me with the deleting empty
folders.
In the first line, I got an error message "Cannot use parentheses when
calling a sub" in which I fixed from a MS article. I had to add Call to the
first line.
After adding that I'm getting error is that I'm getting an error "Object
required: 'fso' in which I'm having a hard time finding the cure.
Here is the code from the post:
DeleteEmptyFolders ("c:\temp", False)
sub DeleteEmptyFolders(sPath, bDeleteThisFolder)
set folder = fso.getfolder(sPath)
'recurse first...
'
for each fldr in folder.subfolders
DeleteEmptyFolders fldr.path,true
next
'if no files or folders then delete...
'
'bDeleteThisFolder is false for
'the root of the subtree, and true for
'sub-folders (unless you want to delete
'the entire subtree if it is empty).
'
if (folder.files.count = 0) and _
(folder.subfolders.count) = 0 and _
bDeleteThisFolder then
on error resume next
folder.delete
exit sub
end if
end sub
"Torgeir Bakken (MVP)" wrote:
> DallasITguy wrote:
>
> > There are/have been post about scripts that delete files by how old they are.
> > Some really good scripts for people like me that are not deep into
> > scripting. Everything that I find is all about deleting files. Is there a
> > way to make the script remove the folder by date or after parsing the files
> > if it's empty? He is a script that I have gotten from the different posts,
> > is there an addition like this to be made?
> >
> > Thanks..
> >
> > (snip coe)
> Hi,
>
> After the file deleting is done, you could make a callout to
> the DeleteEmptyFolders sub found in this post:
>
> http://groups.google.co.uk/group/microsoft.public.scripting.vbscript/msg/0ea7fbd337495cc0?dmode=source&hl=en
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
> http://www.microsoft.com/technet/scriptcenter/default.mspx
>
.
- Follow-Ups:
- Re: Scripts that delete files, not folders.
- From: Torgeir Bakken \(MVP\)
- Re: Scripts that delete files, not folders.
- References:
- Scripts that delete files, not folders.
- From: DallasITguy
- Re: Scripts that delete files, not folders.
- From: Torgeir Bakken \(MVP\)
- Scripts that delete files, not folders.
- Prev by Date: Re: Error using LDAP query
- Next by Date: Re: Scripts that delete files, not folders.
- Previous by thread: Re: Scripts that delete files, not folders.
- Next by thread: Re: Scripts that delete files, not folders.
- Index(es):
Relevant Pages
|