Skip to main content
edited tags
Source Link
jimmij
  • 48.7k
  • 20
  • 136
  • 141

Append SAMEsame timestamp to multiple filenames

I have several files that I ftp each hour. The receiving system needs to have some sort of identifier that they came from the same batch, so I would like to append a timestamp to the filename. That alone is fairly easy, but since I want each file to have the SAMEsame timestamp (so it can serve as the batch identifier), I cannot figure out how to do this.

So, I have:

file1.txt
file2.txt
file3.txt

And I want to have:

file1_20141110184303.txt
file2_20141110184303.txt
file3_20141110184303.txt

Any use of the date +%Y%m%d%H%M%S after the first use will obviously result in a different values in seconds, so I would like to have the first timestamp appended to the remaining files.

Append SAME timestamp to multiple filenames

I have several files that I ftp each hour. The receiving system needs to have some sort of identifier that they came from the same batch, so I would like to append a timestamp to the filename. That alone is fairly easy, but since I want each file to have the SAME timestamp (so it can serve as the batch identifier), I cannot figure out how to do this.

So, I have:

file1.txt
file2.txt
file3.txt

And I want to have:

file1_20141110184303.txt
file2_20141110184303.txt
file3_20141110184303.txt

Any use of the date +%Y%m%d%H%M%S after the first use will obviously result in a different values in seconds, so I would like to have the first timestamp appended to the remaining files.

Append same timestamp to multiple filenames

I have several files that I ftp each hour. The receiving system needs to have some sort of identifier that they came from the same batch, so I would like to append a timestamp to the filename. That alone is fairly easy, but since I want each file to have the same timestamp (so it can serve as the batch identifier), I cannot figure out how to do this.

So, I have:

file1.txt
file2.txt
file3.txt

And I want to have:

file1_20141110184303.txt
file2_20141110184303.txt
file3_20141110184303.txt

Any use of the date +%Y%m%d%H%M%S after the first use will obviously result in a different values in seconds, so I would like to have the first timestamp appended to the remaining files.

Source Link

Append SAME timestamp to multiple filenames

I have several files that I ftp each hour. The receiving system needs to have some sort of identifier that they came from the same batch, so I would like to append a timestamp to the filename. That alone is fairly easy, but since I want each file to have the SAME timestamp (so it can serve as the batch identifier), I cannot figure out how to do this.

So, I have:

file1.txt
file2.txt
file3.txt

And I want to have:

file1_20141110184303.txt
file2_20141110184303.txt
file3_20141110184303.txt

Any use of the date +%Y%m%d%H%M%S after the first use will obviously result in a different values in seconds, so I would like to have the first timestamp appended to the remaining files.