Site icon EasyOraDBA

Shell Script to Add Date to Filenames

Below Shell Script will append Date to all FileNames in Directory with extension .TXT. Also it will create a folder with the Date and move the files to it.

FILE="$(date +%Y%m%d)"
cd /bi_dataload
mkdir -p /bi_dataload/BI_$FILE
for f in *.TXT
mv -n "$f" /bi_dataload/BI_$FILE/"${f%%.*}"_"$FILE".TXT


Exit mobile version