Skip to content

codewithmoss/mkfromtree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mkfromtree

Create complete folder and file structure from a tree text file.

License Build Platform Bash GitHub stars

📸 Screenshots

Using command `mkfromtree /home/moss/Downloads/Backup` created Directories
Using command mkfromtree /home/moss/Downloads/Backup created Directories

Created `TREE.txt` file inside the root directory
Created TREE.txt file inside the root directory

`TREE.txt` file contains the same structure that we input
TREE.txt file contains the same structure that we input


mkfromtree

mkfromtree is a simple Bash script that creates a full directory and file structure from a human-readable tree format.


🚀 Features

  • 📂 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!

📦 Usage

➤ Paste manually (interactive)

mkfromtree

You will be prompted to paste the tree structure manually:

Example:

Directory structure:
└── tree-test/
    ├── README.md
    ├── LICENSE
    └── script.js

Then press Ctrl+D to end input. or Save and exit your EDITOR.


➤ Create from a tree text file

mkfromtree /path/to/tree.txt

Example:

mkfromtree ~/Downloads/mytree.txt

➤ Create in a specific target directory

mkfromtree /target/directory/ /path/to/tree.txt

Example:

mkfromtree ~/Projects/ ~/Downloads/mytree.txt

It will create the structure inside ~/Projects/.

🧩 Commands List

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.

⚙️ How It Works

  • 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.

🧰 Installation

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.

📥 Install from AUR (Arch Linux)

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!

📥 Install using install.sh CURL

✅ 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/.

📜 How it works now:

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!

🪪 License

Released under the MIT License.


About

Create complete folder and file structure from a tree text file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages