Creating a new or blank folder structure from a text file

While cleaning up and organizing my drives, I ran into a situation where I wanted to replicate a folder structure, but not copy any of the files. I'm going to move the files to a new location, but want to keep working and not wait for the folders to copy. Turns out there are a couple of easy ways to accomplish this.

For the first method, create the directory structure you want using a plain text editor. This would be done by creating the path to lowest level folder you may need. You don't need to list all the interim directories.

If I were to list:

"Game Folder/Assets/Icons" it would make all three folders. If the folder name contains spaces, enclose the entire line in quotes. This is a great way to create the same folder structure over an over again for something like a website or coding project.

Next, open Terminal, switch to the new Parent folder where you want to create everything and type:

cat myfolderstructure.txt | xargs mkdir -p

Each folder in the text file will be created at the current location. If you get an errant "?" at the end of your folder name, make sure to save the file as plain text as this usually means a CRLF at the end of the line.

If you already have the folder structure created and want to replicate it, from one drive to another let's say, you can use rsync.

rsync -a /path/from/ /path/to/ --include \*/ --exclude \* [1]
rsync -av -f"+ */" -f"- *" /path/to/src /path/to/dest/ [2]

This may take a few seconds to process, but at the end, you will have a duplicate of your folder structure without any of the files. Very nice if you already have a working model you want to keep using.

Finally, there is a UI way of doing this. Post Haste for Mac, by Digital Rebellion offers a UI way of creating projects and templates. It offers a lot of features including the use of variables to define locations and dragging a folder list onto the window, which it will then replicate.

I just used the command line way to get started, but I think I will start using Post Haste moving forward. I can use it to define coding projects, download folders, and document structures without having to keep track of text files and jumping to the command line.

Best of all, Post Haste is free.

So, there are 3 solid options of creating a new folder structure, from a text file, or from an existing directory without having to type in all the folder names manually. Pretty nice!

post-haste-folders

Other articles of interest:

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Comments
  • Enter dates into a date picker for Chrome and Firefox (1)
    • Prasanna: Hello, How to enter a previous month FIRST day and LAST day from the system date. Thanks Prasanna
  • How To Disable the Quicken Registration Prompt (31)
    • Juani: Hi, I have a registered Quicken 2016 and now my files are being held hostage by Intuit, cannot log in with my ID unless I upgrade therefore buy a subscription, I need to access my files, please HELP. Thanks
    • David: A BIG Thank you! I regularly reinstall Windows OS’s using different hardware configs. In short, Quicken 2011 (it’s March of 2020 as I write this) has been a program I’ve been very happy with and continue to use....
    • Karen L: Today I rang Reckon Australia again, got a different guy and he talked me through the process of getting me a new product key to enter since I already had the licence and it had been extended. Reckon have only extended it by 1...
    • Karen L: I have Australian Quicken 2008 on Windows 8.1. It keeps asking me to renew my licence which Reckon did for me however the activation won’t work. I tried this to disable the registration prompt however it did not stop the...
  • Building Relationships with Developers (1)
    • Carlos Herrera: Ah yes. I have a team of software developers and it is genuinely so hard to keep them in the loop during projects. Though the more we work the better the communication becomes and we go from a trail and error process to a...
  • Integrating DevonAgent Pro with Alfred (1)
    • J. Garr: Beautiful, sweet, and simple. I love it; thanks for posting this solution.
  • Round and Round with the For..Next in Katalon Studio (1)
    • Sweet Ophaline Labador: Hello can you help me how to loop this scenario. Checking the elements is just the same. I want to check that the following function is available in www.siacargo.com: Track Shipment – clicking on this can...
  • Parsing Strings in Katalon – Split, Substring and Readlines (6)
    • Don Pedro: String tempText=”Date Month January. Revenue $1,355,721.00″ println(tempText.split(“ \$”)[1]) You need to escape the $ with \$ The [1] on the split captures characters on the right of the split [0]...
    • Prasad: Hi, I need to get the substring from the below string ‘Date Month January. Revenue $1,355,721.00’ I want to extract text after $ value. Please help Thank you
  • Working with Dates and Date Formatting in Katalon Studio (15)
    • Sangeethaa: How to get previous day’s date(Yesterday’s date)? Actually I was using today.previous() before,it was working fine till today morning.Now its not retrieving right date. Can anyone please guide me on this.
    • Don Pedro: That could be a little tricky. First, is the text/format always going to be the same? You will need to do some parsing. Separate the first but of text at 2019. After that, split the text again to get rid of Central Standard...
    • Don Pedro: It should be of the same Date type as today. You could then do some calendar trickery with Calendar /*Calendar c = Calendar.getInstance(); //c.set(Calendar.MONTH, 1) //Set the month, 0=January, 11=December println...
  • Output status messages and test information by writing to the Log File Viewer in Katalon Studio (6)
    • Saranya: Good One. Could you plz share link to access all your katalon related blogs. ThankQ
    • Rodrigo Calabretta: I’m using the KeywordUtil.markFailed or KeywordUtil.markError and my test stops is being shown as Error and If I use in the @afterTestCase the testCaseContext.getTestCaseSta tus() to show the status test case...