Created
February 4, 2018 03:26
-
-
Save shieva/5996366eb363a532731902db45a4aa6c to your computer and use it in GitHub Desktop.
change timestamp of files in nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const moment = require('moment'); | |
const fs = require('fs'); | |
var Utimes = require('@ronomon/utimes'); | |
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
const folder = '100'; | |
const files = fs.readdirSync(folder); | |
// console.log(files) | |
async function changeTimestamp() { | |
for (const index in files) { | |
const file = files[index]; | |
// await sleep(1000); | |
let btime = + new Date(); | |
btime += (index * 60000) + 48000000; | |
// const btime = moment().add(index, 'mins').unix(); | |
Utimes.utimes(`${folder}/${file}`, btime, btime, btime, (err) => { | |
console.log('err', err) | |
console.log(`${folder}/${file}`); | |
}); | |
} | |
} | |
changeTimestamp(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the module @ronomon/utimes is not working on newer versions on node