tuatara Posted November 1, 2011 Share Posted November 1, 2011 (edited) 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 November 1, 2011 by tuatara Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 1, 2011 Moderators Share Posted November 1, 2011 tuatara, possible to select some files AND folders as inputNo, you need a single folder path as the root for the UDF. 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
tuatara Posted November 2, 2011 Author Share Posted November 2, 2011 (edited) Hi Melba23, First of all thanks for your help AGAIN Of course, perhaps i can shine some light on this, i can imagine it might need that 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 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 November 2, 2011 by tuatara Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2011 Moderators Share Posted November 2, 2011 tuataram, Did you look at my ChooseFileFolder UDF as I suggested? 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. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2011 Moderators Share Posted November 2, 2011 tuatara,Here we go - still needs polishing but it will give you the idea: expandcollapse popup#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) EndFuncIn each case you get the files chosen by the user so you can do what you want with them. 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. All is explained in the UDF - or of course you can take the easy route and ask me directly in the forum. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now