Hello dear Monks,
I need to rename many files (~5,000) in a directory. They have the following structure:
and I need to strip off the first 7 numbers (userID and then year-month-day-hour-minute-second).
The challenge here is that some of them might actually have the same filename remaining after this operation, like the following example:
So, in this case, I would like to keep only the most recent one. To do this, I can use the following simple code I wrote:
$file1 = '2019-3-25T14:40:22';
$file2 = '2019-6-12T22:34:8';
if (str2time( $file1 ) - str2time( $file2 ))
print "$file1 is more recent than $file2\n";
after transforming the dates into the above-mentioned command.
My problem is, how to go about finding and comparing the ones that actually have the same filename, after stripping out the unnecessary information from the beginning - so that I know which ones I need to compare.
any help will be greatly appreciated.