cortx Posted July 15, 2012 Share Posted July 15, 2012 Hello; I want to copy all files *.dat from a folder to an other to backup some files. I've used the function FileCopy but this command don't create every subfolder where some file *.dat are in. #include <Date.au3> #include <Array.au3> #include <File.au3> #include <_FileListToArrayEx.au3> #include <RecFileListToArray.au3> $Dossier_racine = "Z:\test_Backup" $Dossier_a_sauvegarder = "C:\WINDOWS\Temp" $type_fichier_a_sauvegarder = "*.dat" $numsemaine_00 = _WeekNumberISO() $Dossier_backup_semaine_00 = $Dossier_racine & "\" & $numsemaine_00 dircreate($Dossier_backup_semaine_00) FileCopy($Dossier_a_sauvegarder & "\" & $type_fichier_a_sauvegarder, $Dossier_backup_semaine_00, 9) ; Flag = 1 + 8 (overwrite + create target directory structure) The command FileCopy, copy only the files into C:\WINDOWS\Temp but not the files into "C:\WINDOWS\Temp\crt" and dont create this subfolder into my backup folder. How can I do that ? Thanks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 15, 2012 Moderators Share Posted July 15, 2012 cortx,Use my _RecFileListToArray UDF (look in my sig) to list all the *.dat files in the root folder and its subfolders and then loop through the returned array using FileCopy to create the new files. Give it a go yourself - you know where we are if you run into difficulties. 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...
cortx Posted July 15, 2012 Author Share Posted July 15, 2012 Hello; I've already used it for the rest of my script to backup file and delete the old file in other directory, so I think I could handle that. Thank you. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 15, 2012 Moderators Share Posted July 15, 2012 cortx,I've already used it for the rest of my scriptThen you should have no problem at all! 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...
cortx Posted July 15, 2012 Author Share Posted July 15, 2012 (edited) func Sauvegarde_semaine_00() dircreate($Dossier_backup_semaine_00) $FileListbackup = _RecFileListToArray ($Dossier_a_sauvegarder, $type_fichier_a_sauvegarder, 1, 1, 1) If not @Error Then For $i = 1 to $FileListbackup[0] FileCopy($Dossier_a_sauvegarder & "" & $FileListbackup[$i], $Dossier_backup_semaine_00 & "" & $FileListbackup[$i], 9) Next EndIf EndFunc Luke, I'm your Father ;D Yes it's so weak for you but for me that make my day. Edited July 15, 2012 by cortx Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 15, 2012 Moderators Share Posted July 15, 2012 cortx, This is what I had ready if needed: #include <RecFileListToArray.au3> $sRoot = "Your_Old_Path" $sDest = "Your_New_Path" $aList = _RecFileListToArray($sRoot, "*.dat", 1, 1) For $i = 1 To $aList[0] FileCopy($sRoot & $aList[$i], $sDest & $aList[$i], 8) Next Looks pretty close! 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