Skip to content

Instantly share code, notes, and snippets.

@seblavoie
Created September 28, 2012 19:21
Show Gist options
  • Save seblavoie/3801653 to your computer and use it in GitHub Desktop.
Save seblavoie/3801653 to your computer and use it in GitHub Desktop.
Plain text directory structure creation in bash
# Creates folder structure from plain text.
# Based on this stackoverflow question and answer http://stackoverflow.com/questions/12642260/better-bash-script-to-create-directory-structure
mkdirs($file) {
sed -f mkdirs.sed $file | xargs mkdir -p
}
#!/bin/sed -f
s/^//
x
G
: loop
s:\([^/]*\)/*\(.*\n\)\([^|]*\)|\s:\2\3\1/:
t loop
s/.*\n//
s:/*$::
h
folder-01
| subfolder-01
| subfolder-02
| | deeper-subfolder-01
| | deeper-subfolder-02
folder-02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment