I have a bunch of files with a pattern like this:
{UID}-YYMMDD-HHMMSSMM-NEW.xml
Or a real example:
56959-140918-12465122-NEW.XML
I want to copy these files to another directory in date and time order contained within the filename. I also only want to apply this to filenames that match the above pattern.
Are there any tools that exist to do this? If not I imagine a script could be used, something like.
- Match filenames by regex
- match date section by regex then list by date ascending
- for each date match time by regex then list by time ascending add each file to global list.
- Once finished with organising file list copy files
find . -regex
so that directories containing-
doesn't matter? – blarg Sep 18 '14 at 15:19find
searches by default recursively in the current directory. Problems with the sorting order can only occur if files are in subdirectories which have-
in their name. The sorting is based on the relative path to the files, not only the file name. – jofel Sep 18 '14 at 16:04