Jump to content

Recommended Posts

Posted

Hi everyone, I am very new to AutoIt, still learning on it. I have made myself a project. 

image.png.ed42d5418fa6844e1f9505856e07c017.png
I am trying to group the files with the same last 6 digits into a file.
For example, files end with 223344 will move/copy to a folder, while files end with 112233 will move/copy to another folder.  Is it possible?

  • Moderators
Posted

Moved to the appropriate forum.

Moderation Team

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

 

Posted

Hi everyone, I am very new to AutoIt, still learning on it. I have made myself a project. 

image.png.ed42d5418fa6844e1f9505856e07c017.png
I am trying to group the files with the same last 6 digits into a file.
For example, files end with 223344 will move/copy to a folder, while files end with 112233 will move/copy to another folder.  Is it possible?

  • Moderators
Posted (edited)

bboychua,

Welcome to the AutoIt forums.

I would read the files into an array (_FileListToArray) and then loop through the array (For...Next). For each file you could look at the final 6 characters (_StringRight) and then, depending on the result (Switch), move the file to the folder you wish (FileMove).

Try and code something yourself using the functions I mentioned - you know where we are if you run into problems.

M23

Edited by Melba23
Blushes!

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

 

  • Moderators
Posted

bboychua,

Please only post in ONE forum at a time - threads merged.

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

 

Posted
24 minutes ago, Melba23 said:

I would read the files into an array (_FileReadToArray) and then loop through the array (For...Next).

I assume you mean _FileListToArray ;) .

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

  • Moderators
Posted

Musashi,

Ooops! Changed above. Thanks.

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

 

Posted

To start you off :

#include <File.au3>

Local $aFile = _FileListToArray (@ScriptDir, "*.txt", $FLTA_FILES)
_ArrayDisplay ($aFile)
Local $sDir
For $i = 1 To $aFile[0]
  $sDir = StringTrimRight(StringRight($aFile[$i],10),4)
  FileCopy ($aFile[$i],@ScriptDir & "\" & $sDir & "\*.*", $FC_OVERWRITE + $FC_CREATEPATH)
  ConsoleWrite ($sDir & "/" & $aFile[$i] & "/" & @error & @CRLF)
Next

And please use this tool, when you post code.

Posted
2 hours ago, bboychua said:

I am trying to group the files with the same last 6 digits into a file.

I suppose, you want to copy/move files ending with the same 6 digits in the name to another folder (not to a file).
Here is a variation that checks the last 6 digits as well (it can also be solved completely with a regex (without PathSplit).

#include <File.au3>
Global $g_aFilelist = _FileListToArrayRec(@ScriptDir, "*.txt", $FLTAR_FILES, $FLTAR_NORECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH)
Global $g_iLastDigits, $g_aTargetDir, $g_aPathSplit, $g_sDrive = "", $g_sDir = "", $g_sFileName = "", $g_sExtension = ""
$g_aTargetDir  = @ScriptDir & "\home\"
$g_iLastDigits = "123456" ; last 6 digits of the filename
For $iPos = 1 To $g_aFilelist[0]
    $g_aPathSplit = _PathSplit($g_aFilelist[$iPos], $g_sDrive, $g_sDir, $g_sFileName, $g_sExtension)
    If StringRegExp($g_sFileName, "(?i)^.*?" & $g_iLastDigits & "$") Then
        FileCopy($g_aFilelist[$iPos], $g_aTargetDir, BitOR($FC_OVERWRITE, $FC_CREATEPATH))
        ConsoleWrite("+ File matches     : " & $g_aFilelist[$iPos] & "   ==> Copy : ERROR = " & @error & @CRLF)
    Else
        ConsoleWrite("! File not matches : " & $g_aFilelist[$iPos] & @CRLF)
    EndIf
Next

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

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
  • Recently Browsing   0 members

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