I add the below first code to add the current date to the filename and the second one to delete the date.
Is there the possibility to merge both codes and according option execute the part of the code desided.
Like if i want to add the date to the filename choose one option and if i want to remove the date other option.
It is use in daily basis as there some changes in scripts and also to generate a daily backup for some scripts.
Code to add the date to the end of the filename
D=$(date --iso)
for F in *tt*
do
Dot="${F//[^\.]/}" # this removes anything but a dot
if [ -n "$Dot" ]; then
mv "$F" "${F%.*}-$D.${F##*.}"
else
mv "$F" "$F-$D"
fi
done
Code to remove the date from the filename
for file in *tt*
do
chmod 777 $file
mv "$file" "${file%???????????}"
done
Actually i have in separate scripts, then i am looking the possibility to merge boths.
Thanks in advance.