Jump to content

Question about RecFileListToArray.au3 with FileOpenDialog


tuatara
 Share

Recommended Posts

Hi guys,

With the help of Melba23, i am now using the quoted script below,

to copy a directory tree and move the files in it like 'filename.txt' to 'filename.txt.old'

Works great, but is it possible to replace setting of $sOldPath = "Old_Path"

by using the 'FileOpenDialog' like $source = FileOpenDialog ??

To make it possible to select some files AND folders as input and still use RecFileListToArray ?

Normally i use long script for this , because the input can contain 1 or multple files or folders.

#include <RecFileListToArray.au3>

; Declare paths

$sOldPath = "Old_Path"

$sNewPath = "New_Path"

; Get list of files within old path

$aList = _RecFileListToArray($sOldPath, "*.*", 1, 1, 1)

For $i = 1 To $aList[0]

; Copy each of the files to the new path with the added extension

; note use of the "8" flag to create the structure if required

FileCopy($sOldPath & "\" & $aList[$i], $sNewPath & "\" & $aList[$i] & ".old", 8)

Next

Thanks,

Tuatara

Edited by tuatara
Link to comment
Share on other sites

  • Moderators

tuatara,

possible to select some files AND folders as input

No, you need a single folder path as the root for the UDF. :D

Could you explain a little more what you mean by "select some files AND folders as input"? You can already search for multiple file types - do you mean you want to search within multiple folders? If so then you need to get these multiple folders and then run the UDF on them one at a time. You might want to look at my ChooseFileFolder UDF - that will let you choose multiple folders. :oops:

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

Hi Melba23,

First of all thanks for your help AGAIN :D

Of course, perhaps i can shine some light on this, i can imagine it might need that :oops:

In the quoted example above the files are copied to the new tree with a name like 'filename.old',

But in fact, this is just a part of a script i wrote ,which is quite large.

And the "copy to filename.old part" is not really used in my script,

What i do is, i fire a program there that compresses the file with a new kind of compression program i wrote :rip:

So with the script as it is now, i can select 'tree' on drive X: which i copy to drive Y: and Tuatara-compress every file in it. :)

That works great, but if i want to copy-compress , just 1 file, or a few files or, a few files and 1 folder from X: to drive Y: it is not possible.

Another difficulty i ran into was: The first field of the array filled by FileOpenDialog behaves different if you have 1, or multiple files selected ....

In one case it contains a file , in the other case a directory ?!

So all i want to do now, is to make it possible, to:

- make any selection of files and folders on drive X: and copy-compress them in the same structure/tree on drive Y:

Without running 3 separate scripts (what i do now) and ask before you start , something like:

- Do you want to copy-compress 1 file press A

- Do you want to copy-compress multiple files press B

- Do you want to copy-compress a tree press C

Tuatara

Edited by tuatara
Link to comment
Share on other sites

  • Moderators

tuataram,

Did you look at my ChooseFileFolder UDF as I suggested? :D

That will allow you to do exactly that - all you need to do is pass different parameters to the UDF depending on what the user wants to do.

Let me have a think about how best to set it up and I will try to post something later this evening. :oops:

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

  • Moderators

tuatara,

Here we go - still needs polishing but it will give you the idea: :D

#include <GUIConstantsEx.au3>
#include <Array.au3>
#include <ChooseFileFolder.au3>

; Here is the root folder for all the selections
Global $sPath = "C:\Program Files\AutoIt3"

; create our GUI to allow the user to choose his selection type
$hGUI = GUICreate("Test", 500, 500)

GUICtrlCreateLabel("What do you want to compress today?" , 10, 10, 480, 30)
GUICtrlSetFont(-1, 18)
$hBut_OneFile = GUICtrlCreateButton("One File", 10, 50, 180, 50)
$hBut_MulFile = GUICtrlCreateButton("Multiple Files", 10, 120, 180, 50)
$hBut_Tree = GUICtrlCreateButton("All files in a Folder Tree", 10, 190, 180, 50)

GUISetState()

; Get the GUI position to locate the CFF dialog
$aPos = WinGetPos($hGUI)

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hBut_OneFile
            _OneFile()
        Case $hBut_MulFile
            _MulFile()
        Case $hBut_Tree
            _Tree()
    EndSwitch

WEnd

Func _OneFile()

    ; Only allow a single file to be selected
    $sSelection = _CFF_Choose("Choose a file", 300, 500, $aPos[0] + 100, $aPos[1], $sPath)
    ; Display the result
    MsgBox(0, "Selection", $sSelection)

EndFunc

Func _MulFile()

    ; Allow multiple files to be selected
    $sSelection = _CFF_Choose("Choose multiple files", 300, 500, $aPos[0] + 100, $aPos[1], $sPath, "*", 0, False)
    ; Convert the selection into an array
    $aSelection = StringSplit($sSelection, "|")
    ; Display the array
    _ArrayDisplay($aSelection)

EndFunc

Func _Tree()

    ; Only allow the selection of a single folder
    $sSelection = _CFF_Choose("Choose the start folder", 300, 500, $aPos[0] + 100, $aPos[1], $sPath, "*", 2)
    ; Display the folder chosen
    MsgBox(0, "Selection", $sSelection)
    ; List all the files within that folder tree
    $aTree_Content = _RecFileListToArray($sSelection, "*.*", 1, 1, 1, 2)
    ; And display them
    _ArrayDisplay($aTree_Content)

EndFunc

In each case you get the files chosen by the user so you can do what you want with them. :oops:

If you know the folder at the root of the tree from which you are going to choose files/folders, you can prescan the whole tree to speed up the appearance of the list of choices in the dialog - you can also use mouse double-clicks to select items if you use the _CFF_RegMsg function. :rip:

All is explained in the UDF - or of course you can take the easy route and ask me directly in the forum. :)

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

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...