This is a part of my previous question about filenames timestamps correction, i wanted to separate it from the other question so that maybe some of the community member will not have a hard time to find it,

I have a big number of image files spared in many folders under a base directory, and some of the files got a filename with the wrong timestamp, so what i want is to compare the filename timestamp with the creation date of each file and generate a .txt file listing the wrong filenames only.

You can find here an example:
Original filename with false timestamp:
Filename, Created Date, Modified Date
20180524010500530_FR785101.jpg, 2018-05-24 00:05:00, 2018-05-24 00:05:34

The correct filename with correct timestamp is:
Filename, Created Date, Modified Date
20180524000500530_FR785101.jpg, 2018-05-24 00:05:00, 2018-05-24 00:05:34

I started using ls -lc and stat to get the creation time but i still couldn't figure out how i can compare between the filename timestamp and the creation date and generate a .txt listing all the wrong filenames.

So, is there anyone that can help me write a shell script that can do the job ?

  • ls -c does not show creation time. It shows the timestamp of the last change to the inode. – Kusalananda Jun 28 '18 at 9:05
  • Thank you for the correction @Kusalananda but you could at least vote up so that it will be visible for community members that can help – Yacine Walid Jun 28 '18 at 9:19
  • I have clearly mentioned in the header that it is a part from the previous question. It is for making it more visible and easy to find for community members and maybe for people visiting this stackexchange in general – Yacine Walid Jun 28 '18 at 9:37
  • It is not, maybe if you take a look at the previous question, you will make the difference...and maybe you can bring a solution to the question instead of blocking it, right ?! – Yacine Walid Jun 28 '18 at 9:40
  • @Kusalananda done ! i hope it makes sense for you now ! otherwise do not hesitate to suggest more so that the question can reach out people that can help – Yacine Walid Jun 28 '18 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.