Skip to content

Instantly share code, notes, and snippets.

@gabrielfurini
Created May 19, 2015 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielfurini/a53c45e6ac89cfecf7ed to your computer and use it in GitHub Desktop.
Save gabrielfurini/a53c45e6ac89cfecf7ed to your computer and use it in GitHub Desktop.
NODE.JS Redirectr: A simple script to write new folders/files with a content that you desire
/****** NodeJS Redirecter *******/
/* A simple script to write new folders/files based on an array with a content that you desire */
/* IMPORTANT: All folders/files with the same name in the directory will be overwritten */
'use strict';
var fs = require('fs'),
folders = ['folder1', 'folder2', 'folder3'],
fileName = 'index.htm';
folders.forEach(function(folder){
fs.mkdir(__dirname + '/' + folder, function(){
var filePath = __dirname + '/' + folder + '/' + fileName,
content = 'window.location = "http://www.yournewurl.com/'+folder+'";';
fs.writeFile(filePath, content, function(err){
if(err) throw err;
console.log(filePath + ' saved');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment