This is going to be tricky to explain. Here goes:
INPUT
Suppose I have a folder containing several files. All files have datestamps. Thankfully all datestamps are in the format yyyymmdd.
I have read the contents of this folder into a 1 dimensional array which lists all of the filenames (File name only. Does not include the folder path. e.g. "Book1 20191204.xlsx" )
DESIRED OUTPUT
I want a function that will return a 1d array which "filters" the input so that it will list any outdated versions of files. 'Outdated' is determined from filename string pattern and datestamps. See example below.
- aaa 20191204 = REMOVE. only 1x filename with this pattern so no older version
- bbbbb 20191125 = KEEP. There is more than one filename with this pattern and this is NOT the latest datestamp for that pattern
- bbbbb 20191129 = KEEP. There is more than one filename with this pattern and this is NOT the latest datestamp for that pattern
- bbbbb 20191201 = REMOVE. There is more than one filename with this pattern and this is the latest datestamp for that pattern
- aaaaanother_example 20191202 = REMOVE. only 1x filename with this pattern so no older version
I've tried writing this myself but I made a mess of it so I figure uploading this code wouldn't help, only hinder.
In case anyone asks - File extensions. Yes the input array does include file extensions in the file names. I left the extensions out of the example to keep it simpler. Currently files that share the same pattern share the same file extension (In the unlikely event that the file extension is ever different, I would still treat that file as being part of the same group if it shared the same filename pattern - other than the datestamp and extension)
(OPTIONAL) INTENDED USE
If I can identify all of the outdated versions of files in a folder (and ONLY the outdated versions) then I can write a macro which will use this array to move these files into an archival folder. (Or batch delete the outdated versions if that would be preferred)
Bookmarks