-2

I'm looking for a solution using node.js that will copy, move, and rename a file from one directory to another without deleting the original. Other solutions I've found seem to delete the original such as fs.rename.

This will run in a repo using npm.

Stephen Selvey
  • 353
  • 2
  • 3
  • 11
  • 1
    *"that will copy, move, and rename a file from one directory to another without deleting the original"* That's just copying. – gre_gor May 18 '23 at 15:01
  • What in your definition is the difference between "copy, move, and rename" and just doing a copy to a new location with a new name? I.e. why is `fs.copyFile("some/location/someName", "some/otherLocation/someOtherName")` not what you want? – MaxNoe May 18 '23 at 15:53

1 Answers1

2

Standard node:fs module is pretty enough for all of your purposes.
In particular you can achieve your goals with a help of fs.copyFile

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jaood_xD
  • 808
  • 2
  • 4
  • 16