These posted scripts don’t really make sense because they are looping through $files and assigning each row to ‘f’, but then touching the entire array every time.
Also, I don’t like setting the modification time to now for every file. I’d rather set it to creation time because many files like images aren’t modified after written to the disk.
Thus, I’m using this script:
#!/bin/sh
IFS=$'\n'
FILES=$( find . -type f ! -newermt "1971-01-01" )
for FILE in $FILES; do
NEWTIME=$( stat -c %z "$FILE" )
echo "Setting '$FILE' to '$NEWTIME'"
touch -m --date="$NEWTIME" "$FILE"
done