Move Files
Path:
/src/method/move.coffeecompiled to/lib/method/move.js
This will move a single file, complete directory or selection from directory. This is the same as copy the files and remove them afterwards.
To select which files to copy and how to work you can use the following options:
filter-Array<Object>|ObjectFilter Rulesclean-Booleanif set totrueit will clean old files from target.overwrite-Booleanif set totrueit will not fail if destination file already exists and overwrite itignore-Booleanit will not fail if destination file already exists but skip this and go on with the next filenoempty-Booleanset totrue to don't create empty directories while no files to copy intodereference-Booleandereference symbolic links and go into themìgnoreErrors-Booleango on and ignore IO errorsparallel-Integernumber of maximum parallel calls in asynchronous run (defaults to half of open files limit per process on the system)
Example:
CoffeeScript Code fs = require 'alinex-fs'
fs.copy '/tmp/some/directory', '/new/destination', (err) ->
return console.error err.message if err
console.log "Directory copied!"
You may also use options to specify which files within the source directory to move.
move()
Usage:
move(source, target, options, cb)
- Parameter
-
source-Stringpath or file to be copiedtarget-Stringfile or directory to copy tooptions-Objectoptional specifications for check defining which files to copycb-function(<Error>)optional callback which is called after done with possibleÈrror
moveSync()
Usage:
moveSync(source, target, options)
- Parameter
-
source-Stringpath or file to be copiedtarget-Stringfile or directory to copy tooptions-Objectoptional specifications for check defining which files to copy
- Throws
-
Errorif anything out of order happened
Debugging
This module uses thedebug module so you may anytime call your app with
the environment setting DEBUG=fs:move for the output of this method only.
Because there are mkdirs subcalls here you see the output of DEBUG=fs:* while
removeing a small directory:
fs:move move filepath test/temp/dir1 to test/temp/dir4. +26ms
fs:move check test/temp/dir1 +0ms
fs:filter skip because path not included +7ms
fs:filter test/temp/dir1 SKIP +0ms
fs:move check test/temp/dir1/file11 +0ms
fs:filter test/temp/dir1/file11 OK +2ms
fs:mkdirs directory /home/alex/github/node-fs/test/temp/dir4? +0ms
fs:mkdirs directory /home/alex/github/node-fs/test/temp/dir4 created +0ms
fs:move renamed test/temp/dir1 -> test/temp/dir4/file11 +0ms