Smart Rule to delete first two Numbers of File names

Hello,

Until a few years ago I labelled dates on my Files in the YYYYMMDD formate (eg todays date, the 15. September 2021 would be 20210915). I would like to change that to YYMMDD (210915).

With the Change Name function, is there a way to tell DT to only delete the first two digits off a file name? Thanks in advance!

1 Like

It’s possible using regular expressions:

This deletes the first two characters of the name.

1 Like

Thank you! Never would have known that. Will add regular expressions to the list of things to read up on :slight_smile:

Please note that this expression removes _any _ two first characters from the name, not only digits.

This works as expected for me…

  • Look for 8 digits at the beginning
  • If found, strip 2
  • Preserve the rest
  • Use the captured part for the filename
1 Like

Just curious why you’re dropping the century
I use the same naming standard; prefixing the name with the subject date
and I have many dates preceding 2000
(and learned the lesson from Y2K :slightly_smiling_face:)

Your solution of course works, but I’d suggest a sligthly simpler RE:
^\d{2}(\d{6}.*)

There’s no reason to use a zero-width look-ahead pattern here <(?=\d{8})>. You want 8 digits at the start of the name. Since you are going to ignore the first two <\d{2}>, look for 6 more digits <\d{6}> and grab those together with the rest in a capturing group <(\d{6}.*)>.

REs are complicated enough as they are, it is worthwile keeping them as simple as possible. That makes them easier to understand and manage. Also, it reduces the awe factor and might help people to get onto a less steep learning curve with them.

TMN - too many numbers. I find six figure dates are easier to discern.

I’ll cross the bridge of possible issues if I live more than 100 year old, but by then the technology should have evolved to figure it out itself :slight_smile:

This SmartRule is smart and potentially useful to others, so I am bringing it back to the front. Thanks for the insight.