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.

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

 

Category: BashLinuxLinuxShell Script

Tags:

Leave a Reply

Article by: Shadab Mohammad