als-move
v0.1.1
Published
move and rename file without overwriting
Downloads
4
Readme
isExist
isExist
let {isExist} = require('als-move')
let {join} = require('path')
let dirPath = join(__dirname,'src')
let fileName = 'file.txt'
let newFileName = isExist(fileName,dirPath)
// if src/file.txt not exists, newFileName = fileName
// if src/file.txt exists, newFileName = 'file(1).txt'
// if src/file(1).txt exists, newFileName = 'file(2).txt'
// if src folder not exists, creates it
rename
let {rename} = require('als-move')
let {join} = require('path')
let srcFilePath = join(__dirname,'src',fileName)
let newFileName = 'newfile' // rename will add extension
rename(srcFilePath,newFileName)
// If such filename allready exists, add (i)
moveFile
let {moveFile} = require('als-move')
let {join} = require('path')
let srcFilePath = join(__dirname,'src',fileName)
let destDirPath = 'dest'
moveFile(srcFilePath,destDirPath)
// If filename from src has (i), remove it
// If file on destination exists, add to it (i)