jero1987 Posted September 26, 2007 Posted September 26, 2007 Hey i had a real quick question... I want to write a quick script that deletes all folders and subfolders but the ones that i specify. For example i have a folder that contains, Folder1 Folder2 Folder3 and Folder4. I have the variables... $Folder1 = "Folder1" $Folder2 = "Folder2" Now i want to delete everything in that directory except for $folder1 and $folder2. Thanks.
Bert Posted September 26, 2007 Posted September 26, 2007 What have you tried so far? You may simply do a move of the folders to a different area, then delete everything in the folder in question. once done, move the folders back. The Vollatran project My blog: http://www.vollysinterestingshit.com/
jero1987 Posted September 26, 2007 Author Posted September 26, 2007 What have you tried so far? You may simply do a move of the folders to a different area, then delete everything in the folder in question. once done, move the folders back.Well see im trying to delete windows accounts on a lab install. So i cant move out the admin account. I need to clean out all other accounts but the ones specified.
Monamo Posted September 26, 2007 Posted September 26, 2007 Hey i had a real quick question... I want to write a quick script that deletes all folders and subfolders but the ones that i specify. For example i have a folder that contains, Folder1 Folder2 Folder3 and Folder4. I have the variables... $Folder1 = "Folder1" $Folder2 = "Folder2" Now i want to delete everything in that directory except for $folder1 and $folder2. Thanks. Quick and dirty example: #include <File.au3> $FolderRoot = @ScriptDir & "\Test\" $Folder1 = "Folder1" $Folder2 = "Folder2" $AllFolders = _FileListToArray($FolderRoot, "*", 2) If Not @error Then For $i = 1 To $AllFolders[0] If $AllFolders[$i] <> $Folder1 And $AllFolders[$i] <> $Folder2 Then DirRemove($FolderRoot & $AllFolders[$i], 1) EndIf Next EndIf - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]
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