Sorting files based on date in the file name

While doing some scanning I end up with a lot of files named like this:

2026-06-28_11-49-44_6143.tif
2026-06-28_11-49-44_6144.tif
2026-06-28_11-49-44_6145.tif
...
2026-06-28_11-49-44_6171.tif
2026-06-28_11-49-44_6172.tif

2026-06-28_11-51-54_6173.tif
2026-06-28_11-51-54_6174.tif
2026-06-28_11-51-54_6175.tif
...
2026-06-28_11-51-54_6201.tif
2026-06-28_11-51-54_6202.tif

2026-06-28_11-55-17_6203.tif
2026-06-28_11-55-17_6204.tif
...
2026-06-28_11-55-17_6231.tif
2026-06-28_11-55-17_6232.tif

2026-06-28_11-57-25_6233.tif
2026-06-28_11-57-25_6234.tif
2026-06-28_11-57-25_6235.tif
...

Basically the format is YYYY-MM-DD_HH_mm_ss_counter.

I want to put them in folders named for the groups of dates, i.e.

2026-06-28_11-49-44
2026-06-28_11-51-54
2026-06-28_11-55-17
2026-06-28_11-57-25

Is there some way I can automate this? Thanks.

Try this command:

Rename PATTERN="*" TO="*" IGNOREEXT MACRO="L0C19/L0V/L19+\"

Thanks, that works perfectly! I really need to get better with regular expression type things.