Jump to content

Folder names from the combo list?


Recommended Posts

How to folder names from the list to get the combo? :think:

#include <File.au3>
#include <ComboConstants.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 316, 185)
$Button1 = GUICtrlCreateButton("Move", 160, 136, 75, 25)
$Button2 = GUICtrlCreateButton("Count", 25, 136, 75, 25)
$Label1 = GUICtrlCreateLabel("Total desktop :", 24, 24, 118, 17)
$Label2 = GUICtrlCreateLabel("", 144, 24, 156, 17)
$Label4 = GUICtrlCreateLabel("", 32, 48, 228, 17)
$Combo1 = GUICtrlCreateCombo("*.TXT", 32, 88, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "*.JPG|*.PNG|*.GİF")

GUISetState(@SW_SHOW)

While 1
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        case $Button1
            _Move()
        Case $Button2
            _count()

    EndSwitch
WEnd

Func _count()
    Local $extension = GUICtrlRead($Combo1)
    Local $FileList = _FileListToArray(@ScriptDir, $extension, 1)
If IsArray($FileList) Then
        For $i = 0 To UBound($FileList[0])
            Sleep(20)
            GUICtrlSetData ($Label2, $FileList[$i] & $extension & " Is the file")
            For $as = 1 To UBound($FileList) -1
                    Sleep(250)
            GUICtrlSetData ($Label4, $FileList[$as])
            Next
            GUICtrlSetData ($Label4, "")
        Next
        Else
        MsgBox(64,"","On the desktop "& $extension &" Not found!")
        EndIf
    EndFunc

Func _Move()
Local $extension = GUICtrlRead($Combo1)
Local $FileList = _FileListToArray(@ScriptDir, $extension, 1)

For $Move = 0 To UBound($FileList) -1
If FileExists(@DesktopDir & "\& $extension &\") = 1 Then
FileMove(@ScriptDir & '\' & $FileList[$Move],@DesktopDir & "\& $extension & My files\" & $FileList[$Move], 9)
GUICtrlSetData ($Label4, "Moved")
Else

DirCreate(@DesktopDir & "\& $extension & My files")
FileMove(@ScriptDir & '\' & $FileList[$Move],@DesktopDir & "\& $extension & My files\" & $FileList[$Move], 9)
GUICtrlSetData ($Label4, "Moved")
EndIf
Next
EndFunc

 

Link to comment
Share on other sites

  • Moderators

youtuber,

I am afraid that you question makes no sense to me. Are you asking how to get the sub-folder names from within @ScriptDir? And why would you want to put folder names into a combo which currently holds a list of file extensions? Please explain a little more clearly what you are trying to do.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I want to name the folder will only collect extensions

an example, but I do not know :(

#include <File.au3>
#include <ComboConstants.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 316, 185)
$Button1 = GUICtrlCreateButton("Move", 160, 136, 75, 25)
$Button2 = GUICtrlCreateButton("Count", 25, 136, 75, 25)
$Label1 = GUICtrlCreateLabel("Total desktop :", 24, 24, 118, 17)
$Label2 = GUICtrlCreateLabel("", 144, 24, 156, 17)
$Label4 = GUICtrlCreateLabel("", 32, 48, 228, 17)
$Combo1 = GUICtrlCreateCombo("TXT", 32, 88, 65, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "JPG|PNG|GİF")

GUISetState(@SW_SHOW)

While 1
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        case $Button1
            _Move()
        Case $Button2
            _count()

    EndSwitch
WEnd

Func _count()
    Local $extension = GUICtrlRead($Combo1)
    Local $FileList = _FileListToArray(@ScriptDir, "*.", $extension, 1)
If IsArray($FileList) Then
        For $i = 0 To UBound($FileList[0])
            Sleep(20)
            GUICtrlSetData ($Label2, $FileList[$i] & " "& $extension & " Is the file")
            For $as = 1 To UBound($FileList) -1
                    Sleep(25)
            GUICtrlSetData ($Label4, $FileList[$as])
            Next
            GUICtrlSetData ($Label4, "")
        Next
        Else
        MsgBox(64,"","On the desktop "& $extension &" Not found!")
        EndIf
    EndFunc

Func _Move()
Local $extension = GUICtrlRead($Combo1)
Local $FileList = _FileListToArray(@ScriptDir, "*.", $extension, 1)
For $Move = 0 To UBound($FileList) -1
If FileExists(@DesktopDir & "\" & $extension & "\") = 1 Then
FileCopy(@ScriptDir & "\" & $FileList[$Move],@DesktopDir & "\" & $extension & " My files\" & $FileList[$Move], 9)
GUICtrlSetData ($Label4, "Moved")
Else

DirCreate(@DesktopDir & "\" & $extension & " My files")
FileCopy(@ScriptDir & "\" & $FileList[$Move], @DesktopDir & "\" & $extension & " My files\" & $FileList[$Move], 9)
GUICtrlSetData ($Label4, "Moved")
EndIf
Next
EndFunc

 

Link to comment
Share on other sites

  • Moderators

youtuber,

Let me try to follow that code:

- You look for files with a particular extension in @ScriptDir (you should really use "*" as the filter - the "." in the Help file parameter list is actually a period marking the end of the phrase).

- If you find any then:

-- Either count and then display their names, or

-- Look for a folder on the desktop named as that extension (or create one if one is not found)  and copy the found files into that folder.

How is that as a description of what you are trying to do?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

yes exactly right

 

Is this code right?

$FileList = _FileListToArray(@ScriptDir, ".", $extension, 1)

 

Edit: problem solved :) thank you

Local $FileList = _FileListToArray(@ScriptDir, "*." & $extension, 1)

Edited by youtuber
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...