jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.43k stars 775 forks source link

Feature request: dedupe option for fs.move #996

Closed davidmerfield closed 1 year ago

davidmerfield commented 1 year ago

Any interest in an additional option for fs.move which appends a suffix to destination file or folder names if the destination already exists, e.g.

fs.move('a.txt', 'foo.txt', {suffix: true}) // 'a.txt' is now 'foo.txt'
fs.move('b.txt', 'foo.txt', {suffix: true}) // 'b.txt' is now 'foo copy.txt'
fs.move('c.txt', 'foo.txt', {suffix: true}) // 'c.txt' is now 'foo copy 2.txt'

The return value of fs.move would be the final, suffixed path.

I'm not sure if 'suffix' is the appropriate term, perhaps 'dupe', 'rename', 'dedupe'? If there's interest, I'm happy to put together a PR. I've written the code already for my own project

RyanZim commented 1 year ago

I'm going to rule this as out of scope. It's a nice feature for more user-facing applications, but fs-extra tends to focus on developer-facing features (for example, we have remove() but not trash()). Good idea for a standalone npm package, perhaps, though.

davidmerfield commented 1 year ago

Fair enough – thanks for your work on fs-extra