Tuesday, 11 April 2017

Rename .json file node.js

I want to rename a .json file in node.js this file is dynamically generated and located in the folder /export. the file will always start with contentful-export-XXX.json The XXX could be different on the file, and have random numbers and letters in its place. It is not possible to know the full file name before hand. Therefore I would like to rename the file to contentful-export.json instead of contentful-export-XXX.json. I hope this is clear.

Therefore, I believe that I would need to get the file name from the folder export and then insert this into a fs.rename() but I am unsure how to do this.



via jord

No comments:

Post a Comment