Created
August 31, 2012 12:47
Revisions
-
Illyism created this gist
Aug 31, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ 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();