Create complete folder and file structure from a tree text file.
Using command mkfromtree /home/moss/Downloads/Backup
created Directories
Created TREE.txt
file inside the root directory
TREE.txt
file contains the same structure that we input
mkfromtree is a simple Bash script that creates a full directory and file structure from a human-readable tree format.
- 📂 Create complex folder and file structures instantly from a tree text.
- 🏠 Create structure in the current directory or any custom path.
- 📄 Save a copy of the tree structure inside the top directory for reference.
- 🖋️ Supports both manual typing and file input (
tree.txt
). - 🛡️ Smart detection:
- If no tree structure is entered, it does nothing safely.
- Skips empty or invalid lines automatically.
- 🔥 Fully written in pure Bash — no external dependencies needed!
mkfromtree
You will be prompted to paste the tree structure manually:
Directory structure:
└── tree-test/
├── README.md
├── LICENSE
└── script.js
Then press Ctrl+D
to end input.
or Save and exit your EDITOR.
mkfromtree /path/to/tree.txt
Example:
mkfromtree ~/Downloads/mytree.txt
mkfromtree /target/directory/ /path/to/tree.txt
Example:
mkfromtree ~/Projects/ ~/Downloads/mytree.txt
It will create the structure inside ~/Projects/
.
Command | Description |
---|---|
mkfromtree |
Start manual mode — paste the tree structure manually. |
mkfromtree /path/to/tree.txt |
Create structure by reading the tree from a file. |
mkfromtree /target/directory/ /path/to/tree.txt |
Create structure inside a specific target directory. |
mkfromtree /target/directory/ |
Start manual mode but save the result into a specific directory. |
- Parses your tree structure line-by-line.
- Detects folder names (ending with
/
) and creates them. - Detects file names and creates empty files.
- Automatically handles nested directories.
- Also saves a copy of your original tree structure text inside the top folder (
tree-structure.txt
) for your reference.
Clone the repository:
git clone https://github.com/codewithmoss/mkfromtree.git
cd mkfromtree
chmod +x mkfromtree.sh
Add it to your PATH:
sudo cp mkfromtree.sh /usr/local/bin/mkfromtree
✅ Now you can use mkfromtree
anywhere.
You can install mkfromtree easily using any AUR helper like yay
:
yay -S mkfromtree
Or manually clone and build:
git clone https://aur.archlinux.org/mkfromtree.git
cd mkfromtree
makepkg -si
✅ Now you can use mkfromtree anywhere!
✅ Users can install directly with:
curl -fsSL https://raw.githubusercontent.com/codewithmoss/mkfromtree/main/install.sh | bash
✅ This will download and install mkfromtree
automatically to /usr/local/bin/
.
Step | What happens |
---|---|
1 | Downloads the file to a temp location you have access to. |
2 | Uses sudo to move it to /usr/local/bin/ . |
3 | Sets executable permissions. |
4 | Done! |
Released under the MIT License.