Sign in to follow this  
Followers 0
Negro

Code Help [Solved]

13 posts in this topic

#1 ·  Posted (edited)

How to list specific files in the extensions folder and copy it to another folder?

for example :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiComboBoxEx.au3>
#include <File.au3>
Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)
Global $fTypes = "au3|doc|docx|txt|zip|rar|lnk"
$Gui = GUICreate("Desktop Cleaner V1.03", 385, 185, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)
$LV = GUICtrlCreateListView("Desktop Files", 5, 10, 280, 140, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))
FindDesktopFiles()
GUICtrlCreateGroup("File Types", 290, 5, 90, 45)
$Combo = GUICtrlCreateCombo("All Types", 300, 20, 70, 20, $CBS_DROPDOWNLIST)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetData(-1, $fTypes, "All Types")
$SelectAll = GUICtrlCreateButton("Select All", 290, 65, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SelectNone = GUICtrlCreateButton("Select None", 290, 95, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$InvertSeleced = GUICtrlCreateButton("Invert Selected", 290, 125, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SendToBin = GUICtrlCreateButton("Send Selected File(s) To Recycle Bin", 5, 155, 375, 25)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 10, 700)
GUISetState(@SW_SHOW, $Gui)
While 1
    Sleep(100)
WEnd
Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            FindDesktopFiles(GUICtrlRead($Combo))
        Case $SelectAll
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, True)
            Next
        Case $SelectNone
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, False)
            Next
        Case $InvertSeleced
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then
                    _GUICtrlListView_SetItemChecked($LV, $s, False)
                Else
                    _GUICtrlListView_SetItemChecked($LV, $s, True)
                EndIf
            Next
        Case $SendToBin
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then _
                        FileRecycle(@DesktopDir & "\" & _GUICtrlListView_GetItemText($LV, $s, 0))
            Next
            FindDesktopFiles(GUICtrlRead($Combo))
    EndSwitch
EndFunc
Func FindDesktopFiles($sType = "All Types")
    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))
    Local $ext = "*." & $sType, $FL2A
    If $sType = "All Types" Then $ext = "*.*"
    $FL2A = _FileListToArray(@DesktopDir, $ext, 1)
    If Not @error Then
        For $i = 1 To $FL2A[0]
            If $sType = "All Types" Then
                Local $SST = StringSplit($fTypes, "|")
                For $j = 1 To $SST[0]
                    If $SST[$j] = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
                            GUICtrlCreateListViewItem($FL2A[$i], $LV)
                Next
            ElseIf $sType <> "All Types" Then
                If $sType = StringMid($FL2A[$i], StringInStr($FL2A[$i], ".", 0, -1) + 1) Then _
                        GUICtrlCreateListViewItem($FL2A[$i], $LV)
            EndIf
        Next
        _GUICtrlListView_SetColumnWidth($LV, 0, $LVSCW_AUTOSIZE)
    EndIf
EndFunc
Edited by Negro

[font="'Times New Roman"]Everything will be fine[/font]

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

:) file extensions filter ? Edited by Negro

[font="'Times New Roman"]Everything will be fine[/font]

Share this post


Link to post
Share on other sites

Negro,

If you want to search for files with multiple extensions, look at the RecFileListToArray UDF in my sig. :)

If that is not what you are looking for, can you please explain more clearly. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Listing extensions with your function [RecFileListToArray UDF]

As the above example

how do make it ?

My English is not good :)

Edited by Negro

[font="'Times New Roman"]Everything will be fine[/font]

Share this post


Link to post
Share on other sites

Negro,

Have you looked at the thread and the function header? ;)

Here is an example:

#include <Array.au3>
#include "RecFileListToArray.au3"

; Search for files with .sys and .dll extensions only
$aList = _RecFileListToArray("C:\Windows\System32\", "*.sys;*.dll", 1)

_ArrayDisplay($aList)

All clear? :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Melba23,

For example, the beautiful :)

but this is how it should,

please ;)

Edited by Negro

[font="'Times New Roman"]Everything will be fine[/font]

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Negro,

Try this: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiComboBoxEx.au3>
#include <File.au3>

#include "RecFileListToArray.au3" ; You need this <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $fTypes = "au3|doc|docx|txt|zip|rar|lnk"

$Gui = GUICreate("Desktop Cleaner V1.03", 385, 185, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)

$LV = GUICtrlCreateListView("Desktop Files", 5, 10, 280, 140, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))
FindDesktopFiles()
GUICtrlCreateGroup("File Types", 290, 5, 90, 45)
$Combo = GUICtrlCreateCombo("All Types", 300, 20, 70, 20, $CBS_DROPDOWNLIST)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetData(-1, $fTypes, "All Types")
$SelectAll = GUICtrlCreateButton("Select All", 290, 65, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SelectNone = GUICtrlCreateButton("Select None", 290, 95, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$InvertSeleced = GUICtrlCreateButton("Invert Selected", 290, 125, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SendToBin = GUICtrlCreateButton("Send Selected File(s) To Recycle Bin", 5, 155, 375, 25)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 10, 700)

GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            FindDesktopFiles(GUICtrlRead($Combo))
        Case $SelectAll
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, True)
            Next
        Case $SelectNone
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, False)
            Next
        Case $InvertSeleced
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then
                    _GUICtrlListView_SetItemChecked($LV, $s, False)
                Else
                    _GUICtrlListView_SetItemChecked($LV, $s, True)
                EndIf
            Next
        Case $SendToBin
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then _
                        FileRecycle(@DesktopDir & "" & _GUICtrlListView_GetItemText($LV, $s, 0))
            Next
            FindDesktopFiles(GUICtrlRead($Combo))
    EndSwitch
EndFunc

Func FindDesktopFiles($sType = "All Types")

    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))

    Switch $sType
        Case "All Types"
            $ext = "*.au3;*.doc;*.docx;*.txt;*.zip;*.rar;*.lnk" ; Multiple extensions <<<<<<<<<<<<<<
        Case Else
            $ext = "*." & $sType ; Single extension <<<<<<<<<<<<<<<<<<<<
    EndSwitch

    $FL2A = _RecFileListToArray(@DesktopDir, $ext, 1) ; Search here <<<<<<<<<<<<<<<<<<<<<<<<<<
    If Not @error Then
        For $i = 1 To $FL2A[0]
            GUICtrlCreateListViewItem($FL2A[$i], $LV)
        Next
         _GUICtrlListView_SetColumnWidth($LV, 0, $LVSCW_AUTOSIZE)
    EndIf

EndFunc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

KaFu,

Yes As in the picture above. ;)

$sTargetFolder = FileSelectFolder()
For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
    if _GUICtrlListView_GetItemChecked($LV, $s) Then
        FileCopy(@DesktopDir & "" & _GUICtrlListView_GetItemText(),$sTargetFolder)
    endif
Next

:)FileRecycle(@DesktopDir&""&_GUICtrlListView_GetItemText($LV,$s, 0))

I would like to improve the way you say

Melba23,

I think you, understand me :D

but do not delete files

Copy the files where I want :)

As kaFu says, I want to do.

Edited by Negro

[font="'Times New Roman"]Everything will be fine[/font]

Share this post


Link to post
Share on other sites

Please help :)

had very little.


[font="'Times New Roman"]Everything will be fine[/font]

Share this post


Link to post
Share on other sites

Negro,

Sie wurden sehr faul überall, so können Sie herausfinden, was geändert wurde. :)

Trans: You have been very lazy throughout, so you can work out what has been changed.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiComboBoxEx.au3>
#include <File.au3>

#include "RecFileListToArray.au3"

Opt("GUICloseOnESC", 1)
Opt("GUIOnEventMode", 1)

Global $fTypes = "au3|doc|docx|txt|zip|rar|lnk"

$Gui = GUICreate("Desktop Cleaner V1.03", 385, 185, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)

$LV = GUICtrlCreateListView("Desktop Files", 5, 10, 280, 140, -1, BitOR($LVS_EX_CHECKBOXES, $WS_EX_CLIENTEDGE))
FindDesktopFiles()
GUICtrlCreateGroup("File Types", 290, 5, 90, 45)
$Combo = GUICtrlCreateCombo("All Types", 300, 20, 70, 20, $CBS_DROPDOWNLIST)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetData(-1, $fTypes, "All Types")
$SelectAll = GUICtrlCreateButton("Select All", 290, 65, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$SelectNone = GUICtrlCreateButton("Select None", 290, 95, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$InvertSeleced = GUICtrlCreateButton("Invert Selected", 290, 125, 90, 25)
GUICtrlSetOnEvent(-1, "Event")
$CopyTo = GUICtrlCreateButton("Move Selected File(s)", 5, 155, 375, 25)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSetFont(-1, 10, 700)

GUISetState(@SW_SHOW, $Gui)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Combo
            FindDesktopFiles(GUICtrlRead($Combo))
        Case $SelectAll
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, True)
            Next
        Case $SelectNone
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                _GUICtrlListView_SetItemChecked($LV, $s, False)
            Next
        Case $InvertSeleced
            For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                If _GUICtrlListView_GetItemChecked($LV, $s) Then
                    _GUICtrlListView_SetItemChecked($LV, $s, False)
                Else
                    _GUICtrlListView_SetItemChecked($LV, $s, True)
                EndIf
            Next
        Case $CopyTo
            $sDest = FileSelectFolder("Select Destination Folder", "")
            If $sDest Then
                For $s = 0 To _GUICtrlListView_GetItemCount($LV) - 1
                    If _GUICtrlListView_GetItemChecked($LV, $s) Then
                        FileMove(@DesktopDir & "" & _GUICtrlListView_GetItemText($LV, $s, 0), $sDest & "")
                    EndIf
                Next
                FindDesktopFiles(GUICtrlRead($Combo))
            EndIf
    EndSwitch
EndFunc

Func FindDesktopFiles($sType = "All Types")

    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($LV))

    Switch $sType
        Case "All Types"
            $ext = "*.au3;*.doc;*.docx;*.txt;*.zip;*.rar;*.lnk"
        Case Else
            $ext = "*." & $sType
    EndSwitch

    $FL2A = _RecFileListToArray(@DesktopDir, $ext, 1)
    If Not @error Then
        For $i = 1 To $FL2A[0]
            GUICtrlCreateListViewItem($FL2A[$i], $LV)
        Next
         _GUICtrlListView_SetColumnWidth($LV, 0, $LVSCW_AUTOSIZE)
    EndIf

EndFunc

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Melba23,

thank you very much :)

I've tried it but didn't.

Was exactly what I want

best regards..


[font="'Times New Roman"]Everything will be fine[/font]

Share this post


Link to post
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
Sign in to follow this  
Followers 0