t0ddie Posted September 2, 2004 Share Posted September 2, 2004 i want to search for every directory on a drive,(excluding WINDOWS) and place them into variables. then i would like to create an array where i could, for instance... add a .txt file to each one of those directories that the script found. is there a quick and easy way to do this? i am your slave for a week ~Toddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 2, 2004 Developers Share Posted September 2, 2004 i want to search for every directory on a drive,(excluding WINDOWS) and place them into variables. then i would like to create an array where i could, for instance... add a .txt file to each one of those directories that the script found. is there a quick and easy way to do this? i am your slave for a week ~Toddie <{POST_SNAPBACK}>Have a look at this script: http://www.autoitscript.com/fileman/users/jdeb/scriptlets/dirsize.au3 which calculates the total size of all files in all subdirs, but can be easely changed to do what you want... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
t0ddie Posted September 3, 2004 Author Share Posted September 3, 2004 (edited) that script looks pretty neat. easy to change to what i want? lol i am just a beginner with version 3 though. i tried to pick it apart, but have been unsuccessful. this may explain what im trying to do better. ONE) what i want to do, is count every directory, (that script you showed me does that) TWO) what i want to do is put every directories PATH into a variable. (how do i do that?) so, lets say there is for example, 50 directories on the c: drive i should get 50 variables, and they should all be the path to the directory. i would like to search all letter drives, except a: b: and d: of course.... and i would like to make an array that goes through all of the variables, by repeating a loop for whatever amount of directories were found, and then going through each variable, and executing a command for each variable... thanks for the tip, im looking at that script now, but im still kind of stuck any additional help is appreciated ~Todd Edited September 3, 2004 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
t0ddie Posted September 3, 2004 Author Share Posted September 3, 2004 (edited) nice, i changed this in the beginning $FileList = "c:\," to this $FileList = "" and it worked better for me and i am persistant, arent i? lol ~Toddie i prefer to be called, "nice new person" not noob btw, i admit im a noob though, and that you are my hero larry. now, may i borrow your brain? i swear.. i will leave it just how i found it Edited September 3, 2004 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
ezzetabi Posted September 3, 2004 Share Posted September 3, 2004 (edited) Well... it doesn't go in subfolders... it is not so impressive :| Edit: Sorry... I am wrong, read the message below. Edited September 3, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
t0ddie Posted September 3, 2004 Author Share Posted September 3, 2004 moving right along, this is getting interesting! what do you mean subfolders arent included? is the test.txt file i now see on my desktop not a complete list of all folders on my computer? Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
ezzetabi Posted September 3, 2004 Share Posted September 3, 2004 Easy, I am stupid and Larry is great. Link to comment Share on other sites More sharing options...
t0ddie Posted September 15, 2004 Author Share Posted September 15, 2004 ok. currently this script writes the directories into a .txt file. i was wondering how it could be modified to save each directory into a variable instead, so that you could create an array. an example of what i mean by an array. copy a .txt file to each directory by looping through the variable, and adding 1 each time until there are no more variables left. i looked through it, but i would like a little help . im just starting to get used to version 3... thanks for the help. its appreciated!! ~Todd Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
t0ddie Posted September 15, 2004 Author Share Posted September 15, 2004 i mean, it "stacks" all the variables into one variable, and then writes it to a .txt file right? instead of stacking it, can it be re-coded to just put each single directory into a variable? or would you have to make an entirely different script. please? im chain smoking trying to figure this out lol Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Guest BlackDiablo110 Posted September 15, 2004 Share Posted September 15, 2004 Smoking will kill you =/ Link to comment Share on other sites More sharing options...
t0ddie Posted September 15, 2004 Author Share Posted September 15, 2004 damnit, dont make useless replies! *lights a smoke Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
ezzetabi Posted September 15, 2004 Share Posted September 15, 2004 (edited) You should stop smoking... Really. You know, the file is made FROM a variable that can made in a array in A SINGLE LINE! rtfm and the script! $Stack = "c:," $FileList = "c:\," While $Stack <> "" $root = StringLeft($Stack,StringInStr($Stack,",")-1) & "\" $Stack = StringTrimLeft($Stack,StringInStr($Stack,",")) $h = FileFindFirstFile($root & "*.*") If $h > -1 Then $FileFound = FileFindNextFile($h) While Not @Error And $FileFound <> "" If $FileFound <> "." And $FileFound <> ".." And _ StringInStr(FileGetAttrib($root & $FileFound),"D") Then $Stack = $Stack & $root & $FileFound & "," $FileList = $FileList & $root & $FileFound & "\" & @LF;Just changed from @crlf because StringSplit can split using only one char. EndIf $FileFound = FileFindNextFile($h) Wend FileClose($h) EndIf Wend $FileList = StringSplit($FileList,@lf) Now file list is a array with all the dir names, it keeps $filelist[0] elements, indexed from $filelist[1] to $filelist[$filelist[0]] . You can access it with easy using a For $c = 1 to $filelist[0] loop. Edited September 15, 2004 by ezzetabi Link to comment Share on other sites More sharing options...
t0ddie Posted September 15, 2004 Author Share Posted September 15, 2004 i seen the way to do it in the help file, just didnt know where to put it. i KNOW.. i READ the fuggin manual and the script.. heh im bad, your good no but really... THANKS!!! exactly what i wanted ~Todd Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
t0ddie Posted September 21, 2004 Author Share Posted September 21, 2004 (edited) im trying to exclude directories... doesnt seem to be working though i want to list all but the windows directories. not only does it not exclude them.. but it makes for bigger than needed code. $Stack = c:, $FileList = "" Next While $Stack <> "" $root = StringLeft($Stack,StringInStr($Stack,",")-1) & "\" $Stack = StringTrimLeft($Stack,StringInStr($Stack,",")) $h = FileFindFirstFile($root & "*.*") If $h > -1 Then $FileFound = FileFindNextFile($h) While Not @Error And $FileFound <> "" If $FileFound <> "." And $FileFound <> ".." And _ StringInStr(FileGetAttrib($root & $FileFound),"D") Then $Stack = $Stack & $root & $FileFound & "," If StringInStr($root & $FileFound, "WINDOWS") = 0 Then If StringInStr($root & $FileFound, "System") = 0 Then If StringInStr($root & $FileFound, "Documents") = 0 Then If StringInStr($root & $FileFound, "Favorites") = 0 Then If StringInStr($root & $FileFound, "All Users") = 0 Then If StringInStr($root & $FileFound, "Application Data") = 0 Then If StringInStr($root & $FileFound, "Desktop") = 0 Then If StringInStr($root & $FileFound, "Start Menu") = 0 Then If StringInStr($root & $FileFound, "Cookies") = 0 Then If StringInStr($root & $FileFound, "Local Settings") = 0 Then If StringInStr($root & $FileFound, "My Documents") = 0 Then If StringInStr($root & $FileFound, "NetHood") = 0 Then If StringInStr($root & $FileFound, "PrintHood") = 0 Then If StringInStr($root & $FileFound, "SendTo") = 0 Then If StringInStr($root & $FileFound, "Templates") = 0 Then If StringInStr($root & $FileFound, "Programs") = 0 Then If StringInStr($root & $FileFound, "History") = 0 Then If StringInStr($root & $FileFound, "Temporary Internet Files") = 0 Then If StringInStr($root & $FileFound, "Administrative Tools") = 0 Then If StringInStr($root & $FileFound, "Startup") = 0 Then $FileList = $FileList & $root & $FileFound & "\" & @LF EndIf $FileFound = FileFindNextFile($h) Wend FileClose($h) EndIf Wend endif $FileList = StringSplit($FileList,@lf) been fiddling with this code for awhile... its gotten to page 5 now, before i have asked for help lol. what do you think should be changed? Edited September 21, 2004 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
redndahead Posted September 21, 2004 Share Posted September 21, 2004 (edited) I would concantenate the stirings you want to check and then use stirnginstr like $String = '|' & @TempDir & '|' & @Tempdir & '|' If Not stringinstr($String,'|' & $root & $Filefound & '|') Then blah endif red Edited to fix code :"> Edited September 21, 2004 by redndahead Link to comment Share on other sites More sharing options...
t0ddie Posted September 21, 2004 Author Share Posted September 21, 2004 here is a good chunk of the code. should work now. $var = DriveGetDrive( "fixed" ) If NOT @error Then For $i = 1 to $var[0] $Stack = $var[$i] & "," $FileList = "" Next While $Stack <> "" $root = StringLeft($Stack,StringInStr($Stack,",")-1) & "\" $Stack = StringTrimLeft($Stack,StringInStr($Stack,",")) $h = FileFindFirstFile($root & "*.*") If $h > -1 Then $FileFound = FileFindNextFile($h) While Not @Error And $FileFound <> "" If $FileFound <> "." And $FileFound <> ".." And _ StringInStr(FileGetAttrib($root & $FileFound),"D") Then $Stack = $Stack & $root & $FileFound & "," If $root & $FileFound <> @SystemDir And _ $root & $FileFound <> @WindowsDir And _ $root & $FileFound <> @TempDir And _ $root & $FileFound <> @AppDataCommonDir And _ $root & $FileFound <> @DesktopCommonDir And _ $root & $FileFound <> @DocumentsCommonDir And _ $root & $FileFound <> @FavoritesCommonDir And _ $root & $FileFound <> @ProgramsCommonDir And _ $root & $FileFound <> @StartMenuCommonDir And _ $root & $FileFound <> @StartupCommonDir And _ $root & $FileFound <> @AppDataDir And _ $root & $FileFound <> @DesktopDir And _ $root & $FileFound <> @MyDocumentsDir And _ $root & $FileFound <> @FavoritesDir And _ $root & $FileFound <> @ProgramsDir And _ $root & $FileFound <> @StartMenuDir And _ $root & $FileFound <> @StartupDir And _ $root & $FileFound <> @UserProfileDir then $FileList = $FileList & $root & $FileFound & "\" & @LF EndIf EndIf EndIf $FileFound = FileFindNextFile($h) Wend FileClose($h) EndIf Wend endif $FileList = StringSplit($FileList,@lf) so that should create a variable stack with those directories ommitted correct? i changed it in the beginning a little, to search all drives what do you think? Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
t0ddie Posted September 21, 2004 Author Share Posted September 21, 2004 well, it seems to run ok. and i dont get any errors. but either way... they all need to be there. maybe my placement isnt correct, but i think it is. does this code not work for you? and how would you change it to improve it? say there is 5 fixed drives. c: d: e: f: g: with this code. the stacked variable at the end should be every directory in all of these drives, minus the windows folders and stuff. right? Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
t0ddie Posted September 21, 2004 Author Share Posted September 21, 2004 (edited) well, what i did was took a few different examples i liked, and added them together ... but i had to move a few things around.. to make them functional in the loop. its supposed to go through the c drive, make the stack... continue to the d drive afterwards, and keep adding, and so on and so forth so, what needs to be changed? what this is supposed to do, is search all drives, and put every dir into the stacked variable. Edited September 21, 2004 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
t0ddie Posted September 21, 2004 Author Share Posted September 21, 2004 cool, thanks for taking the time to help me. when i ran that, i got test.txt and when i opened it, it looked like this c:\Config.Msi\ c:\Documents and Settings\ c:\Install AOL Communicator\ c:\Install ICQ\ c:\Install Winamp\ c:\My Music\ c:\Program Files\ so on and so on... they are all together, and not on a seperate line each, but i already understand why, cause its lf and not crlf. but anyways.. just wondering why all the directories i didnt want to include are still in there. it didnt seem to weed them out. c:\WINDOWS\$NtUninstallQ817606$\spuninst\ c:\WINDOWS\$NtUninstallQ828026$\spuninst\ c:\WINDOWS\Cache\Adobe Reader 6.0.1\ c:\WINDOWS\Debug\UserMode\ c:\WINDOWS\Downloaded Installations\{5436BB00-FD44-4FFF-B005-AB35C149667C}\ c:\WINDOWS\Driver Cache\i386\ c:\WINDOWS\Help\mail\ c:\WINDOWS\Help\Tours\ c:\WINDOWS\ime\chsime\ c:\WINDOWS\ime\CHTIME\ c:\WINDOWS\ime\imejp\ c:\WINDOWS\ime\imejp98\ c:\WINDOWS\ime\imjp8_1\ c:\WINDOWS\ime\imkr6_1\ c:\WINDOWS\ime\shared\ c:\WINDOWS\Installer\{350C97B0-3D7C-4EE8-BAA9-00BCB3D54227}\ c:\WINDOWS\Installer\{7148F0A8-6813-11D6-A77B-00B0D0142050}\ c:\WINDOWS\Installer\{A14F19F4-2E19-4CA5-83AB-FC9EE3FEA1E0}\ c:\WINDOWS\Installer\{AC76BA86-7AD7-1033-7B44-A00000000001}\ c:\WINDOWS\java\classes\ c:\WINDOWS\java\Packages\ c:\WINDOWS\java\trustlib\ c:\WINDOWS\msagent\chars\ c:\WINDOWS\msagent\intl\ c:\WINDOWS\msapps\msinfo\ c:\WINDOWS\PCHealth\HelpCtr\ c:\WINDOWS\PCHealth\UploadLB\ c:\WINDOWS\provisioning\schemas\ c:\WINDOWS\RegisteredPackages\{44BBA855-CC51-11CF-AAFA-00AA00B6015C}\ c:\WINDOWS\RegisteredPackages\{89820200-ECBD-11cf-8B85-00AA005B4383}\ c:\WINDOWS\RegisteredPackages\{AA936DF4-2B08-4B1F-B071-72192E287704}\ c:\WINDOWS\RegisteredPackages\{CAC24AF7-5447-4F19-9FA6-F6E6E69D395E}\ c:\WINDOWS\RegisteredPackages\{FB8B5424-4B01-433E-AB3B-4B296655D43A}\ c:\WINDOWS\Registration\CRMLog\ c:\WINDOWS\Resources\Themes\ c:\WINDOWS\security\Database\ c:\WINDOWS\security\logs\ c:\WINDOWS\security\templates\ c:\WINDOWS\ServicePackFiles\i386\ c:\WINDOWS\SoftwareDistribution\DataStore\ c:\WINDOWS\SoftwareDistribution\Download\ c:\WINDOWS\SoftwareDistribution\EventCache\ c:\WINDOWS\SoftwareDistribution\SelfUpdate\ c:\WINDOWS\SoftwareDistribution\WebSetup\ c:\WINDOWS\SoftwareDistribution\WuRedir\ c:\WINDOWS\srchasst\chars\ c:\WINDOWS\srchasst\mui\ c:\WINDOWS\Sun\Java\ c:\WINDOWS\system32\1025\ c:\WINDOWS\system32\1028\ c:\WINDOWS\system32\1031\ c:\WINDOWS\system32\1033\ c:\WINDOWS\system32\1037\ c:\WINDOWS\system32\1041\ c:\WINDOWS\system32\1042\ c:\WINDOWS\system32\1054\ c:\WINDOWS\system32\2052\ c:\WINDOWS\system32\3076\ just to name some of them i hope im not TOO annoying lol... but i dont know how i would keep these directories out of the list.. without bungling up the code. Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 21, 2004 Developers Share Posted September 21, 2004 cool, thanks for taking the time to help me. when i ran that, i got test.txt and when i opened it, it looked like this c:\Config.Msi\ c:\Documents and Settings\ c:\Install AOL Communicator\ c:\Install ICQ\ c:\Install Winamp\ c:\My Music\ c:\Program Files\ so on and so on... they are all together, and not on a seperate line each, but i already understand why, cause its lf and not crlf. but anyways.. just wondering why all the directories i didnt want to include are still in there. <{POST_SNAPBACK}>That is because you didn't tell it not to.. e.g. you only told it not to include @WindowsDir = C:\WINDOWS in your case. And "C:\Windows" is NOT equal to 'c:\WINDOWS\$NtUninstallQ817606$\spuninst\ " thus is it included....... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
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