Jabberwock Posted August 9, 2006 Share Posted August 9, 2006 I was looking to clean up the directory listing so that i could easily copy and paste the text for a nullsoft installer, gets really annoying to do it manually with 50 files, or even go a few steps further and add File "filename" any ideas? Directory of C:\Program Files\AutoIt3 7/09/2006 09:35 PM <DIR> . 7/09/2006 09:35 PM <DIR> .. 5/18/2006 06:34 PM 40,448 AU3Info.exe 6/16/2006 05:22 PM <DIR> Aut2Exe 6/21/2004 10:34 AM 64 AutoIt v3 Website.url 8/07/2005 02:55 PM 808,382 AutoIt.chm 3/02/2006 05:27 PM 125,104 AutoIt3.exe 3/26/2006 02:54 AM 15,872 AutoIt3Help.exe 6/16/2006 05:22 PM <DIR> AutoItX 6/21/2006 01:05 PM <DIR> beta 7/09/2006 09:36 PM <DIR> Examples 6/16/2006 05:22 PM <DIR> Extras 7/09/2006 09:35 PM <DIR> Icons 8/07/2006 03:48 PM <DIR> Include 2/04/2004 09:06 AM 45,136 psapi.dll 6/27/2006 05:51 AM <DIR> SciTE 6/16/2006 05:22 PM 55,468 Uninstall.exe Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 9, 2006 Share Posted August 9, 2006 Hi, could you give an example how it should look like when it is done? before : ... after : ... That would make it much easier to help. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Jabberwock Posted August 9, 2006 Author Share Posted August 9, 2006 (edited) Before Directory of C:\Program Files\AutoIt3 7/09/2006 09:35 PM <DIR> . 7/09/2006 09:35 PM <DIR> .. 5/18/2006 06:34 PM 40,448 AU3Info.exe 6/16/2006 05:22 PM <DIR> Aut2Exe 6/21/2004 10:34 AM 64 AutoIt v3 Website.url 8/07/2005 02:55 PM 808,382 AutoIt.chm 3/02/2006 05:27 PM 125,104 AutoIt3.exe 3/26/2006 02:54 AM 15,872 AutoIt3Help.exe 6/16/2006 05:22 PM <DIR> AutoItX 6/21/2006 01:05 PM <DIR> beta 7/09/2006 09:36 PM <DIR> Examples 6/16/2006 05:22 PM <DIR> Extras 7/09/2006 09:35 PM <DIR> Icons 8/07/2006 03:48 PM <DIR> Include 2/04/2004 09:06 AM 45,136 psapi.dll 6/27/2006 05:51 AM <DIR> SciTE 6/16/2006 05:22 PM 55,468 Uninstall.exe After AU3Info.exe AutoIt v3 Website.url AutoIt.chm AutoIt3.exe AutoIt3Help.exe psapi.dll Uninstall.exe That would be great, but if you could even go further and do somthing like this.. SetOutPath "$INSTDIR\" File "AU3Info.exe" File "AutoIt v3 Website.url" File "AutoIt.chm" File "AutoIt3.exe" File "AutoIt3Help.exe" File "psapi.dll" File "Uninstall.exe" SetOutPath "$INSTDIR\AutoItX" File "AutoItX3.dll" File "AutoItX.chm" Just an example of the autoit directory, if it could possibly go into the directories and then populate the list under the correct folder would even be better =) Edited August 9, 2006 by Jabberwock Link to comment Share on other sites More sharing options...
Xenobiologist Posted August 9, 2006 Share Posted August 9, 2006 Hi, you can start with: #Include <File.au3> #Include <Array.au3> $FileList=_FileListToArray(@DesktopDir, "*.*" , 1) If (Not IsArray($FileList)) and (@Error=1) Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf _ArrayDisplay($FileList,"$FileList") So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Jabberwock Posted August 10, 2006 Author Share Posted August 10, 2006 it's pretty much the same thing as what i've been doing, i still have to remove the stuff to the left, just a little less stuff Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 10, 2006 Moderators Share Posted August 10, 2006 (edited) Something like:#Include <File.au3> $Returned = _FileArrange(@DesktopDir) MsgBox(64, 'Info:', $Returned) ClipPut($Returned) Func _FileArrange($hLocation, $sFilter = '*.*', $iFlag = 0) Local $aList = _FileListToArray($hLocation, $sFilter, $iFlag), $aSplit, $sHold If Not IsArray($aList) And @error = 1 Then Return SetError(1, 0, 0) For $iCount = 1 To $aList[0] If FileGetAttrib($hLocation & '\' & $aList[$iCount]) = 'd' Then $sHold &= 'SetOutPath "$INSTDIR\' & $aList[$iCount] & '"' & @CRLF Else $sHold &= 'File "' & $aList[$iCount] & '"' & @CRLF EndIf Next Return StringTrimRight($sHold, 2) EndFunc? Edit: Changed the function to make more sense. Edited August 11, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Jabberwock Posted August 11, 2006 Author Share Posted August 11, 2006 that's exactly what i'm looking for, thanks Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 11, 2006 Moderators Share Posted August 11, 2006 that's exactly what i'm looking for, thanksYou're welcome... I actually used this after I made it on a couple of my own install files... thanks for the idea. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Jabberwock Posted August 11, 2006 Author Share Posted August 11, 2006 i just noticed one thing though, when dealing with the directories, they need to be added at the bottom, or else the files will be installed in the wrong place Link to comment Share on other sites More sharing options...
Jabberwock Posted August 11, 2006 Author Share Posted August 11, 2006 instead of a msg box i made it a edit so you could copy and paste a little easier, i'm not sure why it takes so long to close though. #Include <File.au3> #include <GUIConstants.au3> GuiCreate("Rawr", 389, 316,-1, -1 ) $edit = GUICtrlCreateEdit (""& @CRLF, 0, 0, 390, 320,$ES_AUTOVSCROLL+$WS_VSCROLL) $Returned = _FileArrange("C:\somedir") ClipPut($Returned) GuiCtrlSetData($edit, $Returned) GuiSetState() While 1 Sleep(100) $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect Wend Func _FileArrange($hLocation, $sFilter = '*.*', $iFlag = 0) Local $aList = _FileListToArray($hLocation, $sFilter, $iFlag), $aSplit, $sHold If Not IsArray($aList) And @error = 1 Then Return SetError(1, 0, 0) For $iCount = 1 To $aList[0] If FileGetAttrib($hLocation & '\' & $aList[$iCount]) = 'd' Then $sHold &= 'SetOutPath "$INSTDIR\' & $aList[$iCount] & '"' & @CRLF Else $sHold &= 'File "' & $aList[$iCount] & '"' & @CRLF EndIf Next Return StringTrimRight($sHold, 2) EndFunc Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 11, 2006 Moderators Share Posted August 11, 2006 The message box was only to show you the output it was going to return. ClipPut() would have been what I'd have done. But the GUI is a nice touch. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
jefhal Posted August 11, 2006 Share Posted August 11, 2006 (edited) i just noticed one thing though, when dealing with the directories, they need to be added at the bottom, or else the files will be installed in the wrong placeThis code puts the directories at the bottom of the list. The list is an array in my version. (Edited to correct what goes into the clip buffer):#Include <File.au3> #include <array.au3> Global $sHold[2] $Returned = _FileArrange(@DesktopDir) _ArrayDisplay($sHold,"$sHold") _ArrayToClip($sHold,1) Func _FileArrange($hLocation, $sFilter = '*.*', $iFlag = 0) Local $aList = _FileListToArray($hLocation, $sFilter, $iFlag), $aSplit If Not IsArray($aList) And @error = 1 Then Return SetError(1, 0, 0) For $iCount = 1 To $aList[0] ReDim $sHold[$iCount + 1] If FileGetAttrib($hLocation & '\' & $aList[$iCount]) = 'd' Then $sHold[$iCount] = 'SetOutPath $INSTDIR\' & $aList[$iCount] & @CRLF Else $sHold[$iCount] = "File " & $aList[$iCount] & @CRLF EndIf Next $sHold[0] = $iCount _ArraySort($sHold) Return $sHold EndFunc Edited August 11, 2006 by jefhal ...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 11, 2006 Moderators Share Posted August 11, 2006 (edited) There's a million different ways to do it... No need to add all those functions though:#Include <File.au3> $Returned = _FileArrange(@DesktopDir) MsgBox(64, 'Info:', $Returned) ClipPut($Returned) Func _FileArrange($hLocation, $sFilter = '*.*', $iFlag = 0) Local $aList = _FileListToArray($hLocation, $sFilter, $iFlag) Local $iSwitch, $sHold, $iCount If Not IsArray($aList) And @error = 1 Then Return SetError(1, 0, 0) For $iCount = 1 To $aList[0] If $iSwitch And FileGetAttrib($hLocation & '\' & $aList[$iCount]) = 'd' Then $sHold &= 'SetOutPath "$INSTDIR\' & $aList[$iCount] & '"' & @CRLF ElseIf Not $iSwitch Then $sHold &= 'File "' & $aList[$iCount] & '"' & @CRLF EndIf If Not $iSwitch And $iCount = $aList[0] Then $iSwitch = Not $iSwitch $iCount = 0 EndIf Next Return StringTrimRight($sHold, 2) EndFunc Edit: On why it's taking so long to close, change your Sleep(100) to Sleep(10) Edited August 11, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Jabberwock Posted August 11, 2006 Author Share Posted August 11, 2006 do you think it's possible to populate a file list for the directories below with the files? the sub directories Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 11, 2006 Moderators Share Posted August 11, 2006 do you think it's possible to populate a file list for the directories below with the files? the sub directoriesLike a recursive search? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Jabberwock Posted August 11, 2006 Author Share Posted August 11, 2006 for example, the main directory's files, and the other directories with their files under the correct folder File "text.txt" SetOutPath "$INSTDIR\New" File "New\text.txt" SetOutPath "$INSTDIR\Old" File "Old\text.txt" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 11, 2006 Moderators Share Posted August 11, 2006 for example, the main directory's files, and the other directories with their files under the correct folderFile "text.txt"SetOutPath "$INSTDIR\New"File "New\text.txt"SetOutPath "$INSTDIR\Old"File "Old\text.txt"You don't ask for alot do you lol. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted August 11, 2006 Share Posted August 11, 2006 (edited) i always seem to have problems with thisIf Not IsArray($aList) And @error = 1 Then.....try this$Returned = _FileArrange(@HomeDrive & "\blah")you will get an error/crash... not a returned error #then change to thisIf Not IsArray($aList) OR @error = 1 Then.....and it works fine??8) Edited August 11, 2006 by Valuater Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 12, 2006 Moderators Share Posted August 12, 2006 Jesus... what a pain in the a** this was!expandcollapse popup$Returned = _NSID_FileSetup(@DesktopDir & '\DummyFolder') MsgBox(64, 'Info:', $Returned) ClipPut($Returned) Func _NSID_FileSetup($hLocation) Local $aList = _DirRecurse($hLocation) If @error Then SetError(1, 0, 0) $aList = StringSplit(StringTrimRight($aList, 1), @LF) Local $sHold = 'SetOutPath "$INSTDIR\"' & @CRLF Local $aSplit, $iCount For $iCount = 1 To $aList[0] $aList[$iCount] = StringStripWS($aList[$iCount], 7) If FileGetAttrib($aList[$iCount]) = 'd' Then $aSplit = StringSplit($aList[$iCount], '\') $sHold &= 'SetOutPath "$INSTDIR\' & $aSplit[$aSplit[0]] & '"' & @CRLF While 1 $iCount += 1 If $iCount = $aList[0] + 1 Then ExitLoop If FileGetAttrib($aList[$iCount]) = 'd' Then ExitLoop $aSplit = StringSplit($aList[$iCount], '\') $sHold &= 'File "' & StringTrimRight($aSplit[$aSplit[0]], 1) & '"' & @CRLF WEnd $iCount -= 1 Else $aSplit = StringSplit($aList[$iCount], '\') $sHold &= 'File "' & StringTrimRight($aSplit[$aSplit[0]], 1) & '"' & @CRLF EndIf Next Return StringTrimRight($sHold, 2) EndFunc Func _DirRecurse($hDirectory) RunWait(@Comspec & ' /c dir /b /s /a "' & $hDirectory & '" > "' & _ @TempDir & '\RecursivOutput.txt"', @WorkingDir, @SW_HIDE) If Not FileExists(@TempDir & '\RecursivOutput.txt') Then SetError(1, 0, 0) Local $sFRead = FileRead(@TempDir & '\RecursivOutput.txt') FileDelete(@TempDir & '\RecursivOutput.txt') Return $sFRead EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Jabberwock Posted August 12, 2006 Author Share Posted August 12, 2006 does the trick for 2 folders, can't seem to add more, but with the 2nd directory it has to be specified in every file, for ex. SetOutPath "$INSTDIR\common" File "common\rawr.txt" 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