Create project folder with bash script

Automating Folder Creation for CAE Projects: A Simple Bash Script

As a CAE engineer, managing project files can be a tedious and time-consuming task. You might find yourself manually creating the same folder structure for every new project: an "IN" folder for incoming data, a "WIP" (Work In Progress) folder for your analysis, and an "OUT" folder for final deliverables. This repetitive process is not only inefficient but also prone to human error.

Fortunately, this is a perfect job for a simple automation script. By using a basic Bash script, you can standardize your project file structure and create it in seconds, ensuring consistency and saving valuable time.

The Problem: The Manual Workflow

A typical CAE project workflow involves three main stages, each requiring a dedicated folder:

  • IN Folder: This is where you receive the initial geometry, CAD files, and any other input data from clients or colleagues. You need a way to organize this incoming data with a clear date stamp.

  • WIP Folder: This is your sandbox. It's where you store your simulation models, meshing files, calculation results, and any miscellaneous files you create during the analysis.

  • OUT Folder: Once the analysis is complete, this is where you place the final reports, plots, and a clean version of the simulation results to be delivered.

Manually creating these folders and subfolders for every project is slow and can lead to naming inconsistencies, making it difficult to find files later.

The Solution: A Simple Bash Script

A Bash script is a file containing a series of commands that can be executed by the command-line interpreter. Our script will take a single argument the project name and automatically create the standardized folder structure. This makes it repeatable, fast, and foolproof.

How the Script Works

The script performs the following actions:

  • It checks if a project name was provided as an argument. If not, it prompts the user to enter one.

  • It creates a top-level directory for your project, using the name you provided.

  • Inside the project directory, it creates the main IN, WIP, and OUT folders.

  • Inside the IN folder, it creates a date-stamped subfolder (e.g., 20250913_input_details) to organize incoming data.

  • Inside the WIP folder, it creates three subfolders: model_files, calculations_files, and misc.

  • Finally, inside the OUT folder, it creates a date-stamped subfolder for deliverables, mirroring the structure of the IN folder.

  • This standardized structure ensures that all your projects have the same organization, making it easy for you and your team to navigate files.

The Bash Script

Below is the complete Bash script. You can save this code in a file named create_project.sh.

#!/bin/bash

# Check if a project name was provided as an argument
if [ -z "$1" ]; then
  echo "Usage: ./``create_project.sh`` <project_name>"
  exit 1
fi

PROJECT_NAME=$1
CURRENT_DATE=$(date +"%Y%m%d")

# Create the main project directory
mkdir -p "$PROJECT_NAME"

# Change into the project directory
cd "$PROJECT_NAME"

# Create main folders
mkdir -p IN WIP OUT

# Create subfolders inside IN and OUT with a date stamp
mkdir -p "IN/${CURRENT_DATE}_input_details"
mkdir -p "OUT/${CURRENT_DATE}_output_details"

# Create subfolders inside WIP
mkdir -p "WIP/model_files" "WIP/calculations_files" "WIP/misc"

echo "Project folder structure for '$PROJECT_NAME' created successfully."
echo "Directory tree:"
tree .

To use this script, save it as create_project.sh, make it executable with chmod +x create_project.sh, and then run it from your terminal:

./create_project.sh MyNewAnalysis

This will instantly create a folder structure like this:

MyNewAnalysis/
├── IN/
│   └── 20250913_input_details/
├── OUT/
│   └── 20250913_output_details/
└── WIP/
    ├── calculations_files/
    ├── misc/
    └── model_files/

By investing a few minutes in creating this simple automation script, you can save countless hours over the course of your career and ensure your projects are always organized.

Feel free to modify the folder names and structure in the script to match your specific workflow! If you need support for making customized script as per your requirement, please connect me on email.