chasmant
asked on
Vbscript to delete all folders and files in a directory except to 2 files that are always the same
looking for a script that will clean out all the folders and files in a specified folder with the exception of 2 files that I need to have remain in the folder
any scripts out there?
Thanks
any scripts out there?
Thanks
Forgot the folder part srry.
Add theese lines at the end of the script
For each folder in fso.getfolder(cleanpath).s ubfolders
folder.delete
next
----
The complete script would be:
Set fso=CreateObject("Scriptin g.FileSyst emObject")
CleanPath="path_to_file"
'something like "c:\users\delete"
For Each file In fso.GetFolder(CleanPath).F iles
if (file <> "path_to_file_no_to_delete ") then file.delete
'something like "c:\users\delete\nodelete. exe". Be careful with the path as it is case sensitive.
Next
For each folder in fso.getfolder(cleanpath).s ubfolders
folder.delete
next
Add theese lines at the end of the script
For each folder in fso.getfolder(cleanpath).s
folder.delete
next
----
The complete script would be:
Set fso=CreateObject("Scriptin
CleanPath="path_to_file"
'something like "c:\users\delete"
For Each file In fso.GetFolder(CleanPath).F
if (file <> "path_to_file_no_to_delete
'something like "c:\users\delete\nodelete.
Next
For each folder in fso.getfolder(cleanpath).s
folder.delete
next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great thanks
CleanPath="path_to_file"
'something like "c:\users\delete"
For Each file In fso.GetFolder(CleanPath).F
if (file <> "path_to_file_no_to_delete
'something like "c:\users\delete\nodelete.
Next