Rename
After run the scrip, check back the file name by running ls -l
Script
#! /bin/bash
for i in {1..4};
do
touch "${i}_file.txt"
done
for i in {1..3};
do
touch "image_${i}.jpg"
done
echo "Creating files ... "
sleep 0.5
ls -l
echo "files creation completed! "
###############################
read -p "enter j or t: " choice
while [ $choice != "j" -a $choice != "t" ];
do
echo "wrong letter, retry: "
read choice
done
read -p "write prefix to add to these files: " prefix
echo "the prefix is $prefix "
if [ "$choice" == "t" ]; then
for element in *.txt
do
# echo "txt files are: ${element}"
mv ${element} ${prefix}${element}
done
#else
elif [ "$choice" == "j" ]; then
for element in *.jpg
do
mv ${element} ${prefix}${element}
done
fi