Steal45 Posted January 22, 2021 Share Posted January 22, 2021 is there a way to just copy the (DXF PDF ) files from a directory to a different location So like this Open folder C:\Test\ look inside folder Copy all folder inside c:\test\ to D:\test \ make the folder names the same . Copy only the files *.DXF and *.PDF to that correct folders. Link to comment Share on other sites More sharing options...
Developers Jos Posted January 22, 2021 Developers Share Posted January 22, 2021 Yes that is pretty easy to do. Just open the Helpfile and start reading about and playing with UDF: _FileListToArray() Jos Steal45 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
water Posted January 22, 2021 Share Posted January 22, 2021 (edited) Welcome to AutoIt and the forum! Should be easy. Please have a look at _FileListToArrayRec in the help file on how to get a list of files to copy. Then loop through the array and use FileCopy for each file. Edit: Too slow Edited January 22, 2021 by water Steal45 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
pixelsearch Posted January 22, 2021 Share Posted January 22, 2021 (edited) If I understood correctly, OP would like to : 1) Recreate his folder structure from C:\Test to D:\Test ("make the folder names the same") 2) Then copy *.DXF and *.PDF files to the appropriate folders I tried it with Xcopy (which exists in all Windows releases), here is an example for pdf files : RunWait(@ComSpec & " /c Xcopy C:\Test\*.pdf D:\Test\ /s /e /y", "", @SW_HIDE) If @error Then MsgBox(0, "", "bad lemonade") Explanation for Xcopy parameters : /s take care of subdirectories too... /e ... even if they are empty /y suppress prompting to confirm that you want to overwrite an existing destination file. I just tried it with a test folder structure containing subdirectories (empty or filled with several types of files) and it worked fine : 1) The directory structure was recreated (even the empty subfolders) 2) Only the *.pdf files were copied to their correct locations. Edited January 22, 2021 by pixelsearch Changed Run to RunWait (help file) Steal45 1 Link to comment Share on other sites More sharing options...
Nine Posted January 22, 2021 Share Posted January 22, 2021 If you want to copy all types of files in a single copy, you could use robocopy (robust copy) : #include <Constants.au3> #include <WinAPIConv.au3> $iPID = Run(@ComSpec & ' /c robocopy "c:\apps\temp" "c:\apps\back" *.PDF *.DXF /s /v', "", @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) $sText = StdoutRead($iPID) ConsoleWrite (_WinAPI_OemToChar($sText) & @CRLF) You can get a full report of the job and save it if you want... pixelsearch and Steal45 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Steal45 Posted January 25, 2021 Author Share Posted January 25, 2021 (edited) Thank you for the reply's this is good i can use this Thank you can you also make a filter to only select the folders that start withe the string 2021 Like Folder Name (2021 top) Edited January 25, 2021 by Steal45 Link to comment Share on other sites More sharing options...
Nine Posted January 25, 2021 Share Posted January 25, 2021 (edited) 6 hours ago, Steal45 said: can you also make a filter to only select the folders that start withe the string 2021 Not with robocopy itself. You would need to use _FileListToArrayRec to search for all folders starting with 2021 in the directory tree. Then for each folder found use the robocopy to copy all files : #include <Constants.au3> #include <WinAPIConv.au3> #include <File.au3> Local $aFolder = _FileListToArrayRec("c:\Apps", "2021*", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_RELPATH) If @error Then Exit MsgBox ($MB_SYSTEMMODAL,"","No folder found") Local $iPID, $sResult For $i = 1 to $aFolder[0] $iPID = Run(@ComSpec & ' /c robocopy "c:\Apps\' & $aFolder[$i] & '" "c:\Apps\Backup\' & $aFolder[$i] & '" *.PDF *.DXF /v', "", @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) $sResult &= StdoutRead($iPID) & @CRLF Next ConsoleWrite (_WinAPI_OemToChar($sResult)) Edited January 25, 2021 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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