Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename files in sync from node js [duplicate]

Tags:

node.js

I have some files that I need to copy in another folder and then renaming all of them one by one. Is there any solution to rename all those files in the new folder one by one in synchronous way?

like image 819
ArbaS Avatar asked Mar 13 '19 11:03

ArbaS


1 Answers

The function you're looking for is

fs.renameSync(old_file_path, new_file_path)

You can find it in the node documentation here

Remember you'll need to require in filesystem with const fs = require('fs') as well.

like image 159
OllysCoding Avatar answered Sep 18 '22 15:09

OllysCoding