Created
August 31, 2012 12:47
-
-
Save Illyism/3552285 to your computer and use it in GitHub Desktop.
Folder Creation On Tabs.
This file contains 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 bStrm = new ActiveXObject("Adodb.Stream"); | |
var wShell = new ActiveXObject("Wscript.Shell"); | |
var fso = new ActiveXObject("Scripting.FileSystemObject"); | |
var ForReading = 1, ForWriting = 2, ForAppending = 8; | |
var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0; | |
var debug = false; | |
var root = wShell.CurrentDirectory.split("\\").length; | |
var pDepth = 0; | |
var depth = 0; | |
var previousFolder = ""; | |
if (debug) { | |
WScript.Echo("Starting structure map"); | |
WScript.Echo(wShell.CurrentDirectory); | |
} | |
function goDeeper(aFolder) { | |
return wShell.CurrentDirectory = wShell.CurrentDirectory + "\\"+aFolder+"\\"; | |
} | |
function goHigher() { | |
previousFolder = wShell.CurrentDirectory.split("\\"); | |
previousFolder.pop(); | |
return wShell.CurrentDirectory = previousFolder.join("\\"); | |
} | |
var filename = "D:\\users\\ilias.ismanalijiev\\My Documents\\Structure\\StructureMap.txt"; | |
var fileObj = fso.GetFile(filename); | |
ts = fileObj.OpenAsTextStream(ForReading, TristateUseDefault); | |
while (!ts.AtEndOfStream) { | |
var textLine = ts.ReadLine(); | |
textLine = String(textLine); | |
depth = textLine.split("\t").length - 1; | |
var folderName = textLine.split("\t")[textLine.split("\t").length - 1].substr(0,65); | |
if (depth > pDepth) { | |
goDeeper(previousFolder) | |
} | |
if (depth < pDepth) { | |
for (var i = 0; i <= pDepth - depth-1; i++) | |
{ | |
goHigher(); | |
} | |
} | |
try { | |
fso.CreateFolder(folderName); | |
} catch(e) { | |
if(debug == true) | |
WScript.echo("***ERROR while creating Folder: " + e.description); | |
} | |
previousFolder = folderName; | |
pDepth = depth; | |
} | |
ts.Close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment