Doppio Posted January 14, 2006 Share Posted January 14, 2006 Is there a function that retrieves the folder name? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 14, 2006 Moderators Share Posted January 14, 2006 Folder name of what (where the script is, what your looking at, etc...)? And how do you want to impliment it? 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...
Doppio Posted January 14, 2006 Author Share Posted January 14, 2006 Folder name of what (where the script is, what your looking at, etc...)? And how do you want to impliment it?I backed up about a 100 folders from different users to an external drive, every folder has the user's name as a reference. I would like some script that would read all the folder's names into a combobox. I hope you understand my question.Thank you Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 14, 2006 Moderators Share Posted January 14, 2006 Here this may help you... it returns an array of the names of the folder in that file... I used a test folder to test it on my desktop with 200 folders in it. #include <array.au3> Local $Folder2Search = FileFindFirstFile(@DesktopDir & "\Test Folder\*.*") Local $test = GetClientNames($Folder2Search) _ArrayDisplay($test, 'Names In An Array') Func GetClientNames($s_SearchFolder) Local $nArray Local $Folders While 1 $Folders = $Folders & FileFindNextFile($s_SearchFolder) & Chr(01) If @error Or StringRight($Folders, 2) = Chr(01) & Chr(01) Then ExitLoop WEnd $nArray = StringSplit(StringTrimRight($Folders, 2), Chr(01)) FileClose($s_SearchFolder) Return $nArray 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...
Doppio Posted January 14, 2006 Author Share Posted January 14, 2006 Here this may help you... it returns an array of the names of the folder in that file... I used a test folder to test it on my desktop with 200 folders in it. #include <array.au3> Local $Folder2Search = FileFindFirstFile(@DesktopDir & "\Test Folder\*.*") Local $test = GetClientNames($Folder2Search) _ArrayDisplay($test, 'Names In An Array') Func GetClientNames($s_SearchFolder) Local $nArray Local $Folders While 1 $Folders = $Folders & FileFindNextFile($s_SearchFolder) & Chr(01) If @error Or StringRight($Folders, 2) = Chr(01) & Chr(01) Then ExitLoop WEnd $nArray = StringSplit(StringTrimRight($Folders, 2), Chr(01)) FileClose($s_SearchFolder) Return $nArray EndFunc Nice. Here's a sample combobox script, can you show me how to write the array to the combobox? thank you. expandcollapse popup#include <GUIConstants.au3> #include <GuiCombo.au3> #include <array.au3> #NoTrayIcon ; == GUI generated with Koda == $Form1 = GUICreate("AForm1", 622, 441, 192, 125) $Combo1 = GUICtrlCreateCombo("", 216, 168, 177, 21) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit Local $Folder2Search = FileFindFirstFile("H:\EUB\*.*") Local $test = GetClientNames($Folder2Search) _ArrayDisplay($test, 'Names In An Array') Func GetClientNames($s_SearchFolder) Local $nArray Local $Folders While 1 $Folders = $Folders & FileFindNextFile($s_SearchFolder) & Chr(01) If @error Or StringRight($Folders, 2) = Chr(01) & Chr(01) Then ExitLoop WEnd $nArray = StringSplit(StringTrimRight($Folders, 2), Chr(01)) FileClose($s_SearchFolder) Return $nArray EndFunc Link to comment Share on other sites More sharing options...
Doppio Posted January 14, 2006 Author Share Posted January 14, 2006 Nice. Here's a sample combobox script, can you show me how to write the array to the combobox? thank you. #include <GUIConstants.au3> #include <GuiCombo.au3> #include <array.au3> #NoTrayIcon ; == GUI generated with Koda == $Form1 = GUICreate("AForm1", 622, 441, 192, 125) $Combo1 = GUICtrlCreateCombo("", 216, 168, 177, 21) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit Local $Folder2Search = FileFindFirstFile("H:\EUB\*.*") Local $test = GetClientNames($Folder2Search) _ArrayDisplay($test, 'Names In An Array') Func GetClientNames($s_SearchFolder) Local $nArray Local $Folders While 1 $Folders = $Folders & FileFindNextFile($s_SearchFolder) & Chr(01) If @error Or StringRight($Folders, 2) = Chr(01) & Chr(01) Then ExitLoop WEnd $nArray = StringSplit(StringTrimRight($Folders, 2), Chr(01)) FileClose($s_SearchFolder) Return $nArray EndFunc I found the answer Getting folder names Link to comment Share on other sites More sharing options...
Valuater Posted January 14, 2006 Share Posted January 14, 2006 I found the answer Getting folder names I looked for that post also... #include <GUIConstants.au3> #Include <File.au3> $Location = @ProgramFilesDir $FileList=_FileListToArray($Location, "*.*", 2) If (Not IsArray($FileList)) and (@Error=1) Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf GUICreate("My GUI combo"); will create a dialog box that when displayed is centered GUICtrlCreateCombo ("", 10,10); create first item For $x = 1 to $FileList[0] GUICtrlSetData(-1,$FileList[$x],"|"); add other item send set a new default Next GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend the one i wrote above... worked well for me ( it was in the post ) 8) Link to comment Share on other sites More sharing options...
brotherbbad Posted February 14, 2006 Share Posted February 14, 2006 Hi All, 1. Is it possible to format the result in alphabetical order in the combobox? 2. And how about NOT displaying the "." and ".." filenames, is that also possible, I mean without "jumping" out to comspec ofcourse... Thanks. BBB Link to comment Share on other sites More sharing options...
GaryFrost Posted February 14, 2006 Share Posted February 14, 2006 (edited) #include <GuiConstants.au3> #include <GuiCombo.au3> Opt('MustDeclareVars',1) Dim $Combo,$ret,$Btn_Exit,$Status,$msg,$allocated GuiCreate("ComboBox Add Dir", 392, 254) $Combo = GuiCtrlCreateCombo("", 70, 10, 270, 100,$CBS_SIMPLE) $allocated = _GUICtrlComboInitStorage($Combo, 100, 50) $ret = _GUICtrlComboAddDir($Combo,"D,E",@MyDocumentsDir & "\*") _GUICtrlComboDeleteString($Combo,0) $Btn_Exit = GuiCtrlCreateButton("Exit", 150, 180, 90, 30) $Status = GUICtrlCreateLabel("",0,234,392,20,BitOR($SS_SUNKEN,$SS_CENTER)) GUICtrlSetData($Status,"Pre-Allocated Memory For: " & $allocated & " Items, Folders Added To ComboBox: " & _GUICtrlComboGetCount($Combo)) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Btn_Exit ExitLoop EndSelect WEnd Exit Edited February 14, 2006 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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