1

I'm trying to change the modification timestamps using touch on a group of images that gets accessed by an external program that sorts them by modification date. The current mod times of these files are all exactly the same out to 9 digits, based on how they were created.

Can anyone suggest a way to use touch to change the modification time that's offset within the group of images? It could be offset by 1 min or 1 hour, doesn't matter. I just can't seem to get touch to do this. Am I using the write tool for the job?

Thanks.

Liam
  • 11

1 Answers1

1

The touch command is supposed to set a fixed time.

you can use a script:

#!/bin/bash

# get current time
start=$(date +%s)
# or get time of the first file
start=$(stat -c %X "$1")

for file; do
  touch -d @$start "$file"
  # increment by 1 second
  start=$((start + 1)
  # or by 1 minute
  start=$((start + 60)
done

Call the script with the list of files you want to change.

RalfFriedl
  • 8,981