2025-01-26 12:03:44 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Get the list of directories in the current script directory
|
2025-11-06 19:39:04 +01:00
|
|
|
mapfile -t directories < <(find . -maxdepth 1 -type d ! -name . -printf '%f\n')
|
2025-01-26 12:03:44 +01:00
|
|
|
|
|
|
|
|
# Check if there is exactly one directory
|
|
|
|
|
if [ ${#directories[@]} -ne 1 ]; then
|
|
|
|
|
echo "Error: There should be exactly one folder in the current directory."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Get the name of the single directory
|
|
|
|
|
folder_name=${directories[0]}
|
|
|
|
|
|
|
|
|
|
random_string() {
|
2025-11-06 19:39:04 +01:00
|
|
|
local length="$1"
|
|
|
|
|
tr -dc 'a-zA-Z0-9!@#$%^&*()_+{}|:<>?~' < /dev/urandom | head -c "$length"
|
2025-01-26 12:03:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Number of copies to create (default 100)
|
2025-11-06 19:39:04 +01:00
|
|
|
num_copies="${1:-100}"
|
2025-01-26 12:03:44 +01:00
|
|
|
|
|
|
|
|
# Create the specified number of copies
|
2025-11-06 19:39:04 +01:00
|
|
|
for ((i = 1; i <= num_copies; i++)); do
|
|
|
|
|
new_folder_name="$(random_string 255)"
|
|
|
|
|
cp -r "$folder_name" "$new_folder_name"
|
|
|
|
|
echo "Folder copied and renamed to '$new_folder_name'"
|
|
|
|
|
done
|