Created
January 17, 2015 02:29
-
-
Save gabrielstuff/32548ecc2ef953b65bd3 to your computer and use it in GitHub Desktop.
Rename a file by incrementing its number
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
var fs = require('fs'), | |
schedule = require('node-schedule'), | |
currentfilename = '/Users/gabrielstuff/Desktop/default/iehg', | |
newFilename = '/Users/gabrielstuff/Desktop/default/video', | |
extension = 'mp4', | |
number = 0; | |
function rename() { | |
fs.rename(currentfilename+'.' + extension, newFilename + '_' + number + '.' + extension, function(err) { | |
if (err) { | |
console.log('error moving: ' + err); | |
} | |
currentfilename = newFilename + '_' + number; | |
number++; | |
}); | |
} | |
var readline = require('readline'); | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
// Just to keep the console open | |
rl.question("What do you think of node.js? ", function(answer) { | |
console.log("Thank you for your valuable feedback:", answer); | |
rl.close(); | |
}); | |
setInterval(function(){ | |
rename(); | |
}, 120000); | |
rename(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment