Script to create folders from text file

A script for macos that creates and names individual folders from a .txt file containing the list of names of these; place these dynamically named subfolders in the /Users/shared directory and name the parent folder: subfolders followed by the timestamp


#!/bin/bash
# a script for macos that creates and names individual folders from a .txt file containing the list of names of these; place these dynamically named subfolders in the /Users/shared directory and name the parent folder: subfolders followed by the timestamp
# Get the current timestamp
timestamp=$(date "+%Y.%m.%d-%H.%M.%S")
# Define the parent directory path
parent_dir="/Users/Shared/subfolders_$timestamp"
# Create the parent directory
mkdir "$parent_dir"
# Iterate over each line in the file
while IFS= read -r line
do
# Create a new directory for each line in the file
mkdir "$parent_dir/$line"
done < 'file.txt'

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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