Move Files

Path: /src/method/move.coffee compiled 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 Rules
  • clean - Boolean if set to true it will clean old files from target.
  • overwrite - Boolean if set to true it will not fail if destination file already exists and overwrite it
  • ignore - Boolean it will not fail if destination file already exists but skip this and go on with the next file
  • noempty - Boolean set to true to don't create empty directories while no files to copy into
  • dereference - Boolean dereference symbolic links and go into them
  • ìgnoreErrors - Boolean go on and ignore IO errors
  • parallel - Integer number 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 - String path or file to be copied
  • target - String file or directory to copy to
  • options - Object optional specifications for check defining which files to copy
  • cb - function(<Error>) optional callback which is called after done with possible Èrror

moveSync()

Usage:moveSync(source, target, options)

Parameter
  • source - String path or file to be copied
  • target - String file or directory to copy to
  • options - Object optional specifications for check defining which files to copy
Throws
  • Error if 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