ls -1 *.segd | awk '{printf "touch -t %d.00 %s\n", tt++, $0}' tt=1302081040 | sh
This command works perfect.. But I would like to increment the hour also, when the last minute reach 59..
Example 081059
next file will be 081100
Thanks for your cooperation
---------- Post updated at 04:03 AM ---------- Previous update was at 02:18 AM ----------
Rdrtx1
This script works fine also,
tt=1302081040 for fl in *.segd do touch -t $tt.00 $fl (( tt = tt + 1 )) done
But I notice that it runs the increse the seconds from 0 until 100 interval 1sec,, There is opcion to midify it in order to make the touch -t from 0 to 59, then increase the minute
Example
previous file time 081059
next file time shuold be 081100
This is why I asked if you have GNU date as it does a lot of this time/date processing for us and makes the increment code much simpler (thinking about times close to midnight on the last day of the month).
I notice that your scrip take the date and time for the fist file.
How I can assign a specific date entered manually... for the first file ,, can be a variable.. For example ..
And then your scrip will take this date and make the process...For example .. I will like to start on Feb 08 06:00 and then next file shoulbe Feb 08 06:01.... ...
The main point in this case is that I need to change the time and date stamp, using a old date an time.
Your help is really appreciated.
---------- Post updated at 06:17 AM ---------- Previous update was at 06:00 AM ----------
Yes your solution looks fine, you can improve performance by just using the passed param to set the SECS var like this:
tape=$1
if [ $# -eg 2 ]
then
SECS=$(date -d "$2" +%s)
else
SECS=$(date -d "$2/$3 ${4:-00}:${5:-00}" +%s)
fi
cd /mnt/data1/SEGD/tape"$tape"
for file in *.segd
do
let SECS=SECS+60
touch -t $(date -d @$SECS +%Y%m%d%H%M) "$file"
done
Usage:
fix_timestamps tape datestr fix_timestamps tape month day [hour [min]]>