file.filteredCopy

Syntax file.filteredCopy (sourcepath, destpath, filter)

Params sourcepath is a full path name to the file or folder you wish to copy selectively to the file or folder named in destpath.

destpath is a full path name to the file or folder to which you wish to copy selectively the file or folder named in sourcepath.

filter is the address of a routine that potentially narrows the list of files to be copied by applying some criteria to each file in the folder at sourcepath. This filter might deal with the size of the file, its type, its creation or last modification

date, and so forth.

Action Copies the file or folder at sourcepath to destpath, omitting files and subfolders that are excluded by the filter routine. The routine identified in filter is applied to each file or subfolder encountered as the file hierarchy is traversed. If the file

or subfolder is not excluded by the operation of filter (that is, if that routine returns true), then it is copied. If the file or subfolder is excluded (that is, the routine returns false), it is not copied.

Returns True if all requested files and folders are copied, false otherwise

Examples edit (@examples.filterExample)
Look at the source code for this example. It defines a local script called filter that takes a file path name as an argument. Then it looks at each file in the path and returns true if the file was created on or before September 1, 1991, false if it was
not. The last line of the example uses file.filteredCopy to copy all files that were created before September 1, 1991, to a folder called "System:Early Work:."
Notes The filter script must accept a single parameter that is the path to the current file or subfolder, and must return a boolean result (true or false).

file.filteredCopy is implemented as a script, so you can see its logic readily by jumping to its name.

See Also file.copy

file.visitFolder

Discuss