Sign in to follow this  
Followers 0
youtuber

How to extension to the number of labels to print?

16 posts in this topic

#1 ·  Posted (edited)

Hello friends,how to print the labels extension count?

Extensions folder selected to write the tags with FileSelectFolder

#include <File.au3>
#include <ComboConstants.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $MainTitle = "Title"
Global $aFolder
$Form1 = GUICreate("Form1", 317, 442)
$Button2 = GUICtrlCreateButton("Count", 25, 136, 75, 25)
$Button1 = GUICtrlCreateButton("Move", 160, 136, 75, 25)
$Label1 = GUICtrlCreateLabel("On the desktop :", 24, 24, 118, 17)
$Label2 = GUICtrlCreateLabel("", 144, 24, 156, 17)
$Label4 = GUICtrlCreateLabel("", 32, 48, 228, 17)
$Combo1 = GUICtrlCreateCombo("PSD", 32, 88, 65, 25)
GUICtrlSetData(-1, "JPG|PNG|GIF|ICO|TXT|MP3")
$ButtonBrowse = GUICtrlCreateButton("Browse", 160, 88, 75, 25)
$Label3 = GUICtrlCreateLabel("The Number of all files found :", 24, 184, 128, 17)
$Label5 = GUICtrlCreateLabel("PSD", 24, 216, 26, 17)
$Label6 = GUICtrlCreateLabel("JPG", 24, 248, 24, 17)
$Label7 = GUICtrlCreateLabel("PNG", 24, 280, 27, 17)
$Label8 = GUICtrlCreateLabel("GIF", 24, 312, 21, 17)
$Label9 = GUICtrlCreateLabel("ICO", 24, 344, 22, 17)
$Label10 = GUICtrlCreateLabel("TXT", 24, 376, 25, 17)
$Label29 = GUICtrlCreateLabel("MP3", 24, 408, 26, 17)
$PSDLABEL = GUICtrlCreateLabel("", 72, 216, 42, 17)
$JPGLABEL = GUICtrlCreateLabel("", 72, 248, 42, 17)
$PNGLABEL = GUICtrlCreateLabel("", 72, 280, 42, 17)
$GIFLABEL = GUICtrlCreateLabel("", 72, 312, 42, 17)
$ICOLABEL = GUICtrlCreateLabel("", 72, 344, 42, 17)
$TXTLABEL = GUICtrlCreateLabel("", 72, 376, 42, 17)
$MP3LABEL = GUICtrlCreateLabel("", 72, 408, 42, 17)
$ALLFILESLABEL = GUICtrlCreateLabel("All files", 187, 184, 81, 17)
GUISetState(@SW_SHOW)
While 1
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            _Move()
        Case $Button2
            _count()
      Case $ButtonBrowse
         _FileSelectaFolder()
    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,"","Stated "& $extension &" File 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 & " Archive\" & $FileList[$Move], 9)
GUICtrlSetData ($Label4, "Moved")
Else

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

Func _FileSelectaFolder()
   Local $aFolder = FileSelectFolder("Select folder", "", 1)
   Local $aFolder_1 = $aFolder
   If StringRight($aFolder_1, 1) <> "\" Then $aFolder_1 &= "\"
   If $aFolder_1 = $ScriptDir Then
      MsgBox(16, $MainTitle, "Please select another folder.")
      _FileSelectaFolder()
   EndIf
   $FileList = _FileListToArray($aFolder, "*.*", 1)
  _ArrayDisplay($FileList, "Test array display")
EndFunc

 

Edited by youtuber

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You mean how to get a count of the number of files of each type?

Try something like:

#include <Array.au3>
#NoTrayIcon

Main()

Func Main()
    $_ifiletypes = 2 ; Number of file types we're looking for
    ; Create a 2 dimension array containing the file extension to search for and it's count
    Local $_afiletypes[$_ifiletypes][2] = [["*.txt", 0], ["*.au3", 0]]

    For $loop1 = 0 To $_ifiletypes - 1 Step 1 ; Create a loop to search for each file count
        Local $_hFile = FileFindFirstFile($_afiletypes[$loop1][0]) ; Search for the first file of that file type
        If $_hFile = -1 Then ; If No File with that file type found
            ExitLoop ; Skip the file type and leave the start count was it was
        Else ; Otherwise
            Do
                $_afiletypes[$loop1][1] += 1 ; Add 1 to the file count
                FileFindNextFile($_hFile) ; Look for more of that file
            Until @error ; Stop if no more
            $_afiletypes[$loop1][1] -= 1 ; The above always returns 1 more than there actually is, fix it
        EndIf
        FileClose($_hFile) ; Clean up resources
    Next
    _ArrayDisplay($_afiletypes) ; Display result

EndFunc

 

Edited by rcmaehl
1 person likes this

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

MY PROJECTS


Active: IRC UDF
Discontinued: GithubBubbleSort UDF

Share this post


Link to post
Share on other sites
#AutoIt3Wrapper_Version=b
#include <File.au3>
#include <Array.au3>

Global $sFilters = "*.psd;*.jpg;*.png;*.gif;*.ico;*.txt;*.mp3"
Global $aFilters = StringRegExp($sFilters, "\.(...?)", 3)
Global $aFiltersCounter[UBound($aFilters) + 1][2]

$aResult = _FileListToArrayRec("c:\temp", $sFilters, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_NOPATH)

For $i = 1 To $aResult[0]
    $iPos = _ArraySearch($aFilters, StringRight($aResult[$i], 3))
    $aFiltersCounter[$iPos][1] += 1
Next
For $i = 0 To UBound($aFilters) - 1
    If $aFiltersCounter[$i][1] = "" Then $aFiltersCounter[$i][1] = 0
    $aFiltersCounter[$i][0] = $aFilters[$i]
Next

$aFiltersCounter[UBound($aFiltersCounter) - 1][0] = "Total Files Scanned"
$aFiltersCounter[UBound($aFiltersCounter) - 1][1] = $aResult[0]
_ArrayDisplay($aFiltersCounter, "Extension Counter", "", 0, Default, "Extension|Count")

 

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Thank you @rcmaehl @UEZ 

How to Adding to the label GUICtrlSetData $aFiltersCounter  :think:

;~_ArrayDisplay($aFiltersCounter, "Extension Counter", "", 0, Default, "Extension|Count")

$PSDLABEL = GUICtrlCreateLabel("", 72, 216, 42, 17)
$JPGLABEL = GUICtrlCreateLabel("", 72, 248, 42, 17)
$PNGLABEL = GUICtrlCreateLabel("", 72, 280, 42, 17)
$GIFLABEL = GUICtrlCreateLabel("", 72, 312, 42, 17)
$ICOLABEL = GUICtrlCreateLabel("", 72, 344, 42, 17)
$TXTLABEL = GUICtrlCreateLabel("", 72, 376, 42, 17)
$MP3LABEL = GUICtrlCreateLabel("", 72, 408, 42, 17)
#include <File.au3>
#include <ComboConstants.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $sFilters = "*.psd;*.jpg;*.png;*.gif;*.ico;*.txt;*.mp3"
Global $aFilters = StringRegExp($sFilters, "\.(...?)", 3)
Global $aFiltersCounter[UBound($aFilters) + 1][2]
Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $MainTitle = "Title"
Global $aFolder
$Form1 = GUICreate("Form1", 317, 442)
$Button2 = GUICtrlCreateButton("Count", 25, 136, 75, 25)
$Button1 = GUICtrlCreateButton("Move", 160, 136, 75, 25)
$Label1 = GUICtrlCreateLabel("On the desktop :", 24, 24, 118, 17)
$Label2 = GUICtrlCreateLabel("", 144, 24, 156, 17)
$Label4 = GUICtrlCreateLabel("", 32, 48, 228, 17)
$Combo1 = GUICtrlCreateCombo("PSD", 32, 88, 65, 25)
GUICtrlSetData(-1, "JPG|PNG|GIF|ICO|TXT|MP3")
$ButtonBrowse = GUICtrlCreateButton("Browse", 160, 88, 75, 25)
$Label3 = GUICtrlCreateLabel("The Number of all files found :", 24, 184, 144, 17)
$Label5 = GUICtrlCreateLabel("PSD", 24, 216, 26, 17)
$Label6 = GUICtrlCreateLabel("JPG", 24, 248, 24, 17)
$Label7 = GUICtrlCreateLabel("PNG", 24, 280, 27, 17)
$Label8 = GUICtrlCreateLabel("GIF", 24, 312, 21, 17)
$Label9 = GUICtrlCreateLabel("ICO", 24, 344, 22, 17)
$Label10 = GUICtrlCreateLabel("TXT", 24, 376, 25, 17)
$Label29 = GUICtrlCreateLabel("MP3", 24, 408, 26, 17)
$PSDLABEL = GUICtrlCreateLabel("", 72, 216, 42, 17)
$JPGLABEL = GUICtrlCreateLabel("", 72, 248, 42, 17)
$PNGLABEL = GUICtrlCreateLabel("", 72, 280, 42, 17)
$GIFLABEL = GUICtrlCreateLabel("", 72, 312, 42, 17)
$ICOLABEL = GUICtrlCreateLabel("", 72, 344, 42, 17)
$TXTLABEL = GUICtrlCreateLabel("", 72, 376, 42, 17)
$MP3LABEL = GUICtrlCreateLabel("", 72, 408, 42, 17)
$ALLFILESLABEL = GUICtrlCreateLabel("All files", 187, 184, 81, 17)
GUISetState(@SW_SHOW)
While 1
    Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $Button1
            _Move()
        Case $Button2
            _count()
      Case $ButtonBrowse
         _FileSelectaFolder()
    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,"","Stated "& $extension &" File 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 & " Archive\" & $FileList[$Move], 9)
GUICtrlSetData ($Label4, "Moved")
Else

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

Func _FileSelectaFolder()
   Local $aFolder = FileSelectFolder("Select folder", "", 1)
   Local $aFolder_1 = $aFolder
   If StringRight($aFolder_1, 1) <> "\" Then $aFolder_1 &= "\"
   If $aFolder_1 = $ScriptDir Then
      MsgBox(16, $MainTitle, "Please select another folder.")
      _FileSelectaFolder()
   EndIf
   $aResult = _FileListToArrayRec($aFolder, $sFilters, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_NOPATH)
If @error Then Exit
For $i = 1 To $aResult[0]
    $iPos = _ArraySearch($aFilters, StringRight($aResult[$i], 3))
    $aFiltersCounter[$iPos][1] += 1
Next

For $i = 0 To UBound($aFilters) - 1
    If $aFiltersCounter[$i][1] = "" Then $aFiltersCounter[$i][1] = 0
    $aFiltersCounter[$i][0] = $aFilters[$i]
Next

;$aFiltersCounter[UBound($aFiltersCounter) - 1][0] = "Total Files Scanned"
;$aFiltersCounter[UBound($aFiltersCounter) - 1][1] = $aResult[0]
;_ArrayDisplay($aFiltersCounter, "Extension Counter", "", 0, Default, "Extension|Count")

GUICtrlSetData ($ALLFILESLABEL, $aResult[0])
EndFunc

 

Share this post


Link to post
Share on other sites

You can do it a little bit more dynamic according to your file extensions.

 

Just an idea / suggestion:

#include <File.au3>
#include <ComboConstants.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $sFilters = "*.psd;*.jpg;*.png;*.gif;*.ico;*.txt;*.mp3"
Global $aFilters = StringRegExp($sFilters, "\.(...?)", 3)
Global $aFiltersCounter[UBound($aFilters) + 1][4]
Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $MainTitle = "Title"
Global $aFolder
$Form1 = GUICreate("Form1", 317, 442)
$Button2 = GUICtrlCreateButton("Count", 25, 136, 75, 25)
$Button1 = GUICtrlCreateButton("Move", 160, 136, 75, 25)
$Label1 = GUICtrlCreateLabel("On the desktop :", 24, 24, 118, 17)
$Label2 = GUICtrlCreateLabel("", 144, 24, 156, 17)
$Label4 = GUICtrlCreateLabel("", 32, 48, 228, 17)
$Combo1 = GUICtrlCreateCombo("PSD", 32, 88, 65, 25)
GUICtrlSetData(-1, StringReplace(StringUpper(StringTrimLeft($sFilters, 2)), ";*.", "|"))
$ButtonBrowse = GUICtrlCreateButton("Browse", 160, 88, 75, 25)
$Label3 = GUICtrlCreateLabel("The Number of all files found :", 24, 184, 144, 17)
For $i = 0 to UBound($aFilters) - 1
    $aFiltersCounter[$i][2] = GUICtrlCreateLabel(StringUpper($aFilters[$i]), 24, 216 + $i * 32, 26, 17)
    $aFiltersCounter[$i][3] = GUICtrlCreateLabel("0", 64, 216 + $i * 32, 26, 17)
Next
$ALLFILESLABELSUM = GUICtrlCreateLabel("0", 172, 184, 38, 17)
$ALLFILESLABEL = GUICtrlCreateLabel("All files", 210, 184, 81, 17)

GUISetState(@SW_SHOW)

While 1
;~  Sleep(10)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _Move()
        Case $Button2
            _count()
        Case $ButtonBrowse
            _FileSelectaFolder()
    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, "", "Stated " & $extension & " File Not Found!")
    EndIf
EndFunc   ;==>_count

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 & " Archive\" & $FileList[$Move], 9)
            GUICtrlSetData($Label4, "Moved")
        Else

            DirCreate(@DesktopDir & "\" & $extension & " Archive")
            FileMove(@ScriptDir & "\" & $FileList[$Move], @DesktopDir & "\" & $extension & " Archive\" & $FileList[$Move], 9)
            GUICtrlSetData($Label4, "Moved")
        EndIf
    Next
EndFunc   ;==>_Move

Func _FileSelectaFolder()
    Local $aFolder = FileSelectFolder("Select folder", "", 1)
    Local $aFolder_1 = $aFolder
    If StringRight($aFolder_1, 1) <> "\" Then $aFolder_1 &= "\"
    If $aFolder_1 = $ScriptDir Then
        MsgBox(16, $MainTitle, "Please select another folder.")
        _FileSelectaFolder()
    EndIf
    $aResult = _FileListToArrayRec($aFolder, $sFilters, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_NOPATH)
    If @error Then Exit
    For $i = 1 To $aResult[0]
        $iPos = _ArraySearch($aFilters, StringRight($aResult[$i], 3))
        $aFiltersCounter[$iPos][1] += 1
        GUICtrlSetData($aFiltersCounter[$iPos][3], $aFiltersCounter[$iPos][1])
    Next

    For $i = 0 To UBound($aFilters) - 1
        If $aFiltersCounter[$i][1] = "" Then $aFiltersCounter[$i][1] = 0
        $aFiltersCounter[$i][0] = $aFilters[$i]
    Next

    ;$aFiltersCounter[UBound($aFiltersCounter) - 1][0] = "Total Files Scanned"
    ;$aFiltersCounter[UBound($aFiltersCounter) - 1][1] = $aResult[0]
    ;_ArrayDisplay($aFiltersCounter, "Extension Counter", "", 0, Default, "Extension|Count")

    GUICtrlSetData($ALLFILESLABELSUM, $aResult[0])
EndFunc   ;==>_FileSelectaFolder

 

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Thanks @UEZ should be how to move extensions?

Func _MoveAllextension()
    For $i = 0 to UBound($aFilters) - 1
        If FileExists(@DesktopDir & "\" & $aFiltersCounter[$i][2] & "\") = 1 Then
            FileMove($aFolder & "\" & $aFiltersCounter[$i][3], @DesktopDir & "\" & $aFilters & " Archive\" & $aFiltersCounter[$i], 9)
            GUICtrlSetData($Label4, "Moved")
        Else
            DirCreate(@DesktopDir & "\" & $aFiltersCounter[$i][2] & " Archive")
            FileMove($aFolder & "\" & $aFiltersCounter[$i][2], @DesktopDir & "\" & $aFilters & " Archive\" & $aFiltersCounter[$i], 9)
            GUICtrlSetData($Label4, "Moved")
        EndIf
    Next
EndFunc

 

Share this post


Link to post
Share on other sites

Should this be?

Func _FileSelectaFolder()
    Local $aFolder = FileSelectFolder("Select folder", "", 1)
    Local $aFolder_1 = $aFolder
    If StringRight($aFolder_1, 1) <> "\" Then $aFolder_1 &= "\"
    If $aFolder_1 = $ScriptDir Then
        MsgBox(16, $MainTitle, "Please select another folder.")
        _FileSelectaFolder()
    EndIf
    $aResult = _FileListToArrayRec($aFolder, $sFilters, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_NOPATH)
    If @error Then Exit
    For $i = 1 To $aResult[0]
        $iPos = _ArraySearch($aFilters, StringRight($aResult[$i], 3))
        $aFiltersCounter[$iPos][1] += 1
        GUICtrlSetData($aFiltersCounter[$iPos][3], $aFiltersCounter[$iPos][1])
    Next

    For $i = 0 To UBound($aFilters) - 1
        If $aFiltersCounter[$i][1] = "" Then $aFiltersCounter[$i][1] = 0
        $aFiltersCounter[$i][0] = $aFilters[$i]
    Next
    GUICtrlSetData($ALLFILESLABELSUM, $aResult[0])

Select
    Case $Button1
    For $i = 0 to UBound($aFilters) - 1
        If FileExists(@DesktopDir & "\" & $aFiltersCounter[$i][2] & "\") = 1 Then
            FileMove($aFolder & "\" & $aFiltersCounter[$i][3], @DesktopDir & "\" & $aFilters[$i] & " Archive\" & $aFiltersCounter[$i], 9)
            GUICtrlSetData($Label4, "Moved")
        Else
            DirCreate(@DesktopDir & "\" & $aFiltersCounter[$i][2] & " Archive")
            FileMove($aFolder & "\" & $aFiltersCounter[$i][3], @DesktopDir & "\" & $aFilters[$i] & " Archive\" & $aFiltersCounter[$i], 9)
            GUICtrlSetData($Label4, "Moved")
        EndIf
    Next
EndSelect
EndFunc   ;==>_FileSelectaFolder

 

Share this post


Link to post
Share on other sites

Please can you help in this regard.

How can I create a folder names? :(

Share this post


Link to post
Share on other sites

No idea what it is you're asking in that last post.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Posting a runable (reproducer) script showing your issue will give better results.

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Try this:

#include <File.au3>
#include <ComboConstants.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


Global $sFilters = "*.psd;*.jpg;*.png;*.gif;*.ico;*.txt;*.mp3"
Global $aFilters = StringRegExp($sFilters, "\.(...?)", 3)
Global $aFiltersCounter[UBound($aFilters) + 1][4]
Global $ScriptDir = @ScriptDir
If StringRight($ScriptDir, 1) <> "\" Then $ScriptDir &= "\"
Global $MainTitle = "Title"
Global $aFolder, $aFiles
$Form1 = GUICreate("Form1", 317, 442)
$Button2 = GUICtrlCreateButton("Count", 25, 136, 75, 25)
$Button1 = GUICtrlCreateButton("Move", 160, 136, 75, 25)
$Label1 = GUICtrlCreateLabel("On the desktop :", 24, 24, 118, 17)
$Label2 = GUICtrlCreateLabel("", 144, 24, 156, 17)
$Label4 = GUICtrlCreateLabel("", 32, 48, 228, 17)
$Combo1 = GUICtrlCreateCombo("PSD", 32, 88, 65, 25)
GUICtrlSetData(-1, StringReplace(StringUpper(StringTrimLeft($sFilters, 2)), ";*.", "|"))
$ButtonBrowse = GUICtrlCreateButton("Browse", 160, 88, 75, 25)
$Label3 = GUICtrlCreateLabel("The Number of all files found :", 24, 184, 144, 17)
For $i = 0 to UBound($aFilters) - 1
    $aFiltersCounter[$i][2] = GUICtrlCreateLabel(StringUpper($aFilters[$i]), 24, 216 + $i * 32, 26, 17)
    $aFiltersCounter[$i][3] = GUICtrlCreateLabel("0", 64, 216 + $i * 32, 26, 17)
Next
$ALLFILESLABELSUM = GUICtrlCreateLabel("0", 172, 184, 38, 17)
$ALLFILESLABEL = GUICtrlCreateLabel("All files", 210, 184, 81, 17)

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _Move($ScriptDir, $aFiles, GUICtrlRead($Combo1))
        Case $Button2
            _count()
        Case $ButtonBrowse
            $aFiles = _FileSelectaFolder()
    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, "", "Stated " & $extension & " File Not Found!")
    EndIf
EndFunc   ;==>_count

Func _Move($ScriptDir, $aFiles, $sExt)
    Local $i, $c = 0, $sDestDir = $ScriptDir & $sExt & " Archive"
    If Not FileExists($sDestDir) Then DirCreate($sDestDir)
    For $i = 1 To $aFiles[0]
        Switch StringRight($aFiles[$i], 3)
            Case $sExt
                If FileCopy($aFiles[$i], $sDestDir, $FC_NOOVERWRITE) Then $c += 1
;~              If FileMove($aFiles[$i], $sDestDir, $FC_NOOVERWRITE) Then $c += 1
        EndSwitch
    Next
    If Not $c Then
        MsgBox(64, "Information", "No files with extension " & $sExt & " were moved!", 30)
    Else
        MsgBox(64, "Information", "Moved " & $c & " files with extension " & $sExt & " to " & $sDestDir, 30)
    EndIf
EndFunc   ;==>_Move

Func _FileSelectaFolder()
    Local $aFolder = FileSelectFolder("Select folder", "", 1)
    Local $aFolder_1 = $aFolder
    If StringRight($aFolder_1, 1) <> "\" Then $aFolder_1 &= "\"
    If $aFolder_1 = $ScriptDir Then
        MsgBox(16, $MainTitle, "Please select another folder.")
        _FileSelectaFolder()
    EndIf
    Local $aResult = _FileListToArrayRec($aFolder, $sFilters, $FLTAR_FILES, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)
    If @error Then Exit

    For $i = 1 To $aResult[0]
        $iPos = _ArraySearch($aFilters, StringRight($aResult[$i], 3))
        $aFiltersCounter[$iPos][1] += 1
        GUICtrlSetData($aFiltersCounter[$iPos][3], $aFiltersCounter[$iPos][1])
    Next

;~     For $i = 0 To UBound($aFilters) - 1
;~         If $aFiltersCounter[$i][1] = "" Then $aFiltersCounter[$i][1] = 0
;~         $aFiltersCounter[$i][0] = $aFilters[$i]
;~     Next

    ;$aFiltersCounter[UBound($aFiltersCounter) - 1][0] = "Total Files Scanned"
    ;$aFiltersCounter[UBound($aFiltersCounter) - 1][1] = $aResult[0]
    ;_ArrayDisplay($aFiltersCounter, "Extension Counter", "", 0, Default, "Extension|Count")

    GUICtrlSetData($ALLFILESLABELSUM, $aResult[0])
    Return $aResult
EndFunc   ;==>_FileSelectaFolder

 

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

No no

that's what i want

The selected folder to move all extensions

Share this post


Link to post
Share on other sites
25 minutes ago, youtuber said:

No no

that's what i want

The selected folder to move all extensions

Come on youtuber, that's not more difficult than doing it by the extension only -> a little homework for you.

1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

@UEZ 

:shifty:

For $Moveall = 0 To UBound($aResult) - 1
    FileMove($aFolder & "\" & $aFilters[$Moveall], @DesktopDir & "\" & StringUpper($aFilters[$Moveall]) & " Archive\" & $aFilters[$Moveall], 9)
    Next

 

:doh:

For $Moveall = 0 To UBound($aResult) - 1
       FileMove($aFolder & "\" & $aResult[$Moveall], @DesktopDir & "\" & StringUpper($aFilters[$Moveall]) & " Archive\" & _
       $aFiltersCounter[UBound($aFiltersCounter) - 1][0], 9)
     Next
Edited by youtuber

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