- I am trying to write automation script using node js what i am trying 
   to achieve is I have packages in one machine and install those packages in 
   another machine..i need to write a script for it..
   - packages has config and jar files... I need to open the config file 
   and change the installer value and execute the .exe file
   - For example in the config file i have value like this PPP.install= 
   iphone
   - I need to change it to
   - PPP.install= android
   - and after that I need to execute .exe file. both config and exe file 
   are in the same folder.
   - right now what I have achieved is i can copy all these files in to a 
   another folder I need to unzip and zip it too.. not sure how to achieve... 
   can i copy all these files in to a another folder
   - providing my code below
   


var fs = require('fs');var path = require('path');
/*function dateFormat(){
    var date = new Date();
    var year  = (date.getFullYear() + '').slice(2);
    var month = (date.getMonth() + 1) < 10 ? '0' + (date.getMonth() + 1) : 
(date.getMonth() + 1);
    var day   = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
    return year+month+day;
}*/function moveAndRename(sourceDir, destDir){
    fs.readdir(sourceDir, function(err, files){
        if(err)
            return err;
        else {
            files.forEach(function(file){
                var dotIndex = file.lastIndexOf(".");
                var name = file.slice(0, dotIndex);

                //var newName = (name + dateFormat()) + path.extname(file);
                var newName = (name) + path.extname(file);

                var read = fs.createReadStream(path.join(sourceDir, file));
                var write = fs.createWriteStream(path.join(destDir, newName));
                read.pipe(write);
            });
        }
    });}

moveAndRename("C:/here/Desktop/screenshots/folder1",
              "C:/here/Desktop/screenshots/folder2")

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/2fce9b35-f1ce-493b-9733-bb10b0d4d23b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to