move in ksh

Hello everybody:

I wanted to rename some files by adding date at the end. I wanted to assign the new name to a variable. Following is the code

REMOTE_FILE="/abc/data/test.csv"

mv /abc/data/test.csv /abc/data/"`date '+test_%Y%m%d'`".csv

REMOTE_FILE="/abc/data/"`date '+test_%Y%m%d'`".csv"

Question:

  1. Is the above code correct? The expected result would be 'test_20081112.csv'
  2. There are multiple files e.g. test1.csv, test2.csv, test3.csv; I believe I have to use loop as following but not sure.

for each in *.csv;
do
mv $each /abc/data/"`date '+test_%Y%m%d'`".csv
done

I would appreciate any help.
Thanks.

Guess the only true way to know is to test it :slight_smile: