2013-08-24

An Example of Copying Files

For example, there are these files in my computer disk system:
C:\tmp\a\001.txt
C:\tmp\a\002.txt
C:\tmp\b\001.txt
C:\tmp\b\002.txt

and I want to copy them to another directory with renaming like this:
C:\tmp\folder\a_001.txt
C:\tmp\folder\a_002.txt
C:\tmp\folder\b_001.txt
C:\tmp\folder\b_002.txt

Directory and File Pathnames Reader and File Copy Writer are very useful to do such a operation.

Directory and File Pathnames Reader retrieves properties of every file in the specified directories, creates non-spatial features having attributes named "path_****". Each attribute stores a file property - file full path, directory path, file name, extension etc.
Source Directory and File Pathnames Directory: C:\tmp\a,C:\tmp\b

FilenamePartExtractor extracts parts of the file path.
Source File Name: path_windows
Full Filename Attribute: _filename
Directory Name Attribute: _dirname

AttributeCreator renames the attribute storing source file path, and creates the destination filename as a new attribute. "filecopy_****" is a format attribute of the File Copy Writer.
Attribute Name <- Value
filecopy_source_dataset <- path_windows
filecopy_dest_filename <- @Value(_dirname)_@Value(_filename)

File Copy Writer copies "filecopy_source_dataset" to "filecopy_dest_filename" in the specified directory.
Destination File Copy Directory: C:\tmp\folder

This is likely to be applicable in various scenes.

No comments:

Post a Comment