Here is a list of methods to create a directory structure from a text file. These methods will result you a restored directory structure on the disk. The following methods suppose that you have already created a backup of your directory structure in a text file, or you have created folder structure in a text file.
Let’s have a look on different methods to create directories from information stored in a text file.
Text 2 Folders
Text 2 Folders is a very small and easy to use software that can create a directory structure on the disk by reading a text file. It’s a portable software so, you don’t have to wait for the software to install. Just launch it from any directory and provide an input text file and a root folder path where you want to restore the directory structure. As you click on Create Folders, you will see a directory structure is restored on that location.
You can also type/copy text directly into the software manually by checking the Manual radio button. This option is useful in case your directory backup maker software don’t provide a text file output.
Do ensure that the file that has folder structure is in plain text format and doesn’t include any other information except folder name and path. So. you have to make sure that your file should contain name and paths only otherwise it will create folder with the name of that extra information.
When I restored the backup of my directory structure with Text 2 Folders, I got the following output.
Create Folder Structure from Text File using Command Prompt:
You can restore a backup of the directory structure using Windows Command Prompt. You will require a text file containing the directory structure information and Windows Command window with administrator rights. Now go through the following steps and restore the directory structure from the backup text file.
Step 1: Open folder where your text file is saved and in the same folder open command prompt using Shift+Right-Click.
Step 2: Now execute the following command:
for /F "usebackq delims=" %a IN ("backup.txt") DO mkdir "%a"
In the above command, replace backup.txt with the name of the text file in which you have stored information about the folder structure.
If you want to run the above command through a batch file then you have to replace % sign with %% to make it work properly. After you are done, you will see the following output.
Using a VB Script
In Windows you can create directory structure directly from a text file via running a small VB Script.
Step 1: Open Notepad and paste the following code in it and replace “C:\ilovefreesoftware\backup.txt” with the absolute path of your backup text file:
'START
dim objFileSys, objReadFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objFileSys = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFileSys.OpenTextFile("C:\ilovefreesoftware\backup.txt", ForReading)
Do until objReadFile.AtEndOfStream = True
objFileSys.CreateFolder(objReadFile.ReadLine)Loop
objReadFile.Close
Set objReadFile = Nothing
Set objFileSys = Nothing
'STOP
Step 2: Save this file with .vbs extension and run it by double clicking on it or you can open it with Command Prompt. You will see a Command window will blink for a very short period of time and that’s it, you are done. You can navigate to the location where your directory structure was supposed to be created.
My Final Verdict
These were the methods that I found to restore a directory structure from a backup text file. Even though all these methods results in same output, but I really like restoring directory structure backup using Command prompt as it doesn’t require you to download and install anything.
I hope you will not find it difficult to use these methods explained in above article.