eJan Posted June 11, 2005 Posted June 11, 2005 I'm trying to make script which will check if "@AppDataCommonDir (\001)" doesn't contain any file or subfolder except "\001" which contain files and subfolders inside and delete @AppDataCommonDir if no other files or folders exists.
/dev/null Posted June 11, 2005 Posted June 11, 2005 $empty = 1 $savedpath = @WorkingDir FileChangeDir(@AppDataCommonDir) $search = FileFindFirstFile("*.*") While $empty $file = FileFindNextFile($search) If @error Then ExitLoop if $file = "." OR $file = ".." OR $file = "001" then continueloop $empty = 0 WEnd FileChangeDir($savedpath) Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
eJan Posted June 11, 2005 Author Posted June 11, 2005 Thanks Kurt, but I couldn't get it to work, this is what it looks like:My point is to extract files B:\Documents and Settings\All Users\Application Data\001 to RamDrive, to use files for some time then delete 001 and @AppDataCommonDir if any other folder or file doesn't exist inside @AppDataCommonDir. On RamDrive @AppDataCommonDir doesn't exist by default.
Westi Posted June 11, 2005 Posted June 11, 2005 #include <Constants.au3> $dirs = Run(@ComSpec & " /c dir /AD /B", @AppDataCommonDir, @SW_HIDE, $STDOUT_CHILD) $alldirs = "" While 1 $alldirs = $alldirs & StdoutRead($dirs) If @error = -1 Then ExitLoop Wend MsgBox(0, @AppDataCommonDir, $alldirs)
/dev/null Posted June 11, 2005 Posted June 11, 2005 (edited) Thanks Kurt, but I couldn't get it to work, this is what it lookswhat exactly does not work? My code checks if @AppDataCommonDir holds only \001. If so, the variable $empty will be set to 1. If there is anything else in @AppDataCommonDir, then the variable will be set to 0. You will have to write your own code to delte or copy files based on that information.BTW: The screenshot does not match your textual description. Is that intentional?CheersKurt Edited June 11, 2005 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
blindwig Posted June 13, 2005 Posted June 13, 2005 Have a look at my _FileFindAll() functionIt returns a list of files that match a mask and an attribute filter. This usage:_FileFindAll(@AppDataCommonDir, '*', 'D')will return an array containing the names of folders in @AppDataCommonDir. If the first element isn't '001' or the array is bigger than one, then you know there are more folders out there. My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
eJan Posted June 13, 2005 Author Posted June 13, 2005 what exactly does not work? My code checks if @AppDataCommonDir holds only \001. If so, the variable $empty will be set to 1. If there is anything else in @AppDataCommonDir, then the variable will be set to 0. You will have to write your own code to delte or copy files based on that information.I have tried this way:$empty = 1 $savedpath = @WorkingDir FileChangeDir("D:\ZZ") $search = FileFindFirstFile("*.*") While $empty $file = FileFindNextFile($search) If @error Then ExitLoop If $file = "." Or $file = ".." Or $file = "001" Then DirRemove("D:\ZZ\001", 1) Else DirRemove("D:\ZZ", 1); does not remove dir (only content) EndIf $empty = 0 WEnd FileChangeDir($savedpath)Everything goes fine until Else, where DirRemove delete only files and folders inside "ZZ" but does not remove complete dir [DirRemove("D:\ZZ", 1)].
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