#!/bin/bash
ls -ltr folder1 > list-of-files-1.txt
ls -ltr folder2 > list-of-files-2.txt
i=1
while read line; do
if [ "cat list-of-files-1.txt | head -$i | tail -1" = "$line" ]; then
put-1-wherever-you-want
i=$i+1
fi
done < list-of-files-2.txt
Explanation: You should do 2 lists of files. After that, you have to compare those lists by line. If both lists have the same element in the same position, you can put a number 1 wherever you want.