FileCopy Example #2 issues

Share your ideas as to how the documentation can be improved.
JBensimon
Posts: 118
Joined: 19 Nov 2017, 11:19

FileCopy Example #2 issues

Post by JBensimon » 25 Apr 2021, 21:20

Example #2 on the FileCopy documentation page has a bug, may be misleading, and could be replaced with something more useful:

Bug: The line

Code: Select all

Loop, %SourcePattern%, 2  ; 2 means "retrieve folders only". 
should read

Code: Select all

Loop, Files, %SourcePattern%, 2  ; 2 means "retrieve folders only".
Also, the description of function

Code: Select all

CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false)
may give the impression that it will copy an entire folder tree of files matching a given pattern (a common need), when in fact it will copy all files matching the pattern in the source root plus the entire contents of subfolders with names matching the pattern (a rather unusual need).

Finally, since the pattern used in the example is *.*, the entire example could have been performed by a single FileCopyDir call and is therefore of little interest. Rather, since FileCopyDir lacks a file pattern parameter (unlike XCopy and RoboCopy), the example function could with very few changes be made recursive rather than use FileCopyDir to achieve a directory copy function with a file pattern feature, thus plugging the hole in the FileCopyDir functionality.

JB

lexikos
Posts: 9560
Joined: 30 Sep 2013, 04:07
Contact:

Re: FileCopy Example #2 issues

Post by lexikos » 29 Apr 2021, 02:13

Examples using deprecated syntax should be updated, but to be clear, Loop, %SourcePattern%, 2 is a perfectly valid file pattern loop using deprecated syntax.

I think if you're only copying some of the files in a folder, you're not copying the folder.

Post Reply

Return to “Suggestions on Documentation Improvements”