`
Par2: Copy all files in one directory to another 2002-12-11 -- John Christ > Is there a simple way to copy all the files in one folder to another? There may be a simpler way, but this works: GLOBAL embeds, Before File Declarations SHFileOp LIKE(SHFILEOPgroup) ! ! Shell File Operations ! FO_MOVE EQUATE(0001h) FO_COPY EQUATE(0002h) FO_DELETE EQUATE(0003h) FO_RENAME EQUATE(0004h) FOF_MULTIDESTFILES EQUATE(0001h) FOF_CONFIRMMOUSE EQUATE(0002h) FOF_SILENT EQUATE(0004h) ! don't create progress/report FOF_RENAMEONCOLLISION EQUATE(0008h) FOF_NOCONFIRMATION EQUATE(0010h) ! Don't prompt the user. FOF_WANTMAPPINGHANDLE EQUATE(0020h) ! Fill in SHFILEOPSTRUCT.hNameMappings ! Must be freed using SHFreeNameMappings FOF_ALLOWUNDO EQUATE(0040h) FOF_FILESONLY EQUATE(0080h) ! on *.*, do only files FOF_SIMPLEPROGRESS EQUATE(0100h) ! means don't show names of files FOF_NOCONFIRMMKDIR EQUATE(0200h) ! don't confirm making any needed dirs FOF_NOERRORUI EQUATE(0400h) ! don't put up error UI FOF_NOCOPYSECURITYATTRIBS EQUATE(0800h) ! dont copy NT file Security Attributes FOF_NORECURSION EQUATE(1000h) ! don't recurse into directories. FOF_NO_CONNECTED_ELEMENTS EQUATE(2000h) ! don't operate on connected elements. FOF_WANTNUKEWARNING EQUATE(4000h) ! during delete operation, warn if nuking instead of recycling (partially overrides FOF_NOCONFIRMATION) SHFILEOPgroup GROUP, TYPE hwnd UNSIGNED wFunc UNSIGNED pFrom LONG pTo LONG fFlags USHORT fAnyOperationsAborted LONG hNameMappings LONG lpszProgressTitle LONG END ========== GLOBAL embeds, Inside the Global Map MODULE('Windows.lib') SHFileOperation(LONG pSHFILEOPgroup), LONG, PASCAL, RAW, DLL, NAME('SHFileOperationA') END ========== Data Source CSTRING(256) Destination CSTRING(256) ========== Insert this where you want to perform the copy: Source = 'C:\TheSourceDirectory\*.*' & '<0>' Destination = 'C:\TheDestinationDirectory' CLEAR(SHFileOp) SHFileOp.hWnd = 0{PROP:Handle} SHFileOp.wFunc = FO_COPY SHFileOp.pFROM = ADDRESS(Source) SHFileOp.pTo = ADDRESS(Destination) SHFileOp.fFlags = FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR I# = SHFileOperation(ADDRESS(SHFileOp)) Printed November 21, 2024, 11:34 am This article has been viewed/printed 35224 times. |