Deleting, moving, and copying files
Factor handbook > Input and output > Directory manipulation

Prev:Creating directories
Next:Directory hierarchy manipulation


The operations for moving and copying files come in three flavors:
A word named operation which takes a source and destination path.
A word named operation-into which takes a source path and destination directory. The destination file will be stored in the destination directory and will have the same file name as the source path.
A word named operations-into which takes a sequence of source paths and destination directory.

Since both of the above lists apply to copying files, that this means that there are a total of six variations on copying a file.

Deleting files:
delete-file ( path -- )

delete-directory ( path -- )


Moving files:
move-file ( from to -- )

move-file-into ( from to -- )

move-files-into ( files to -- )


Copying files:
copy-file ( from to -- )

copy-file-into ( from to -- )

copy-files-into ( files to -- )


On most operating systems, files can only be moved within the same file system. To move files between file systems, use copy-file followed by delete-file on the old name.