File Mover Blog

March 18, 2025

Strip date from filename filter and move files older than the x days

Strip date from filename filter and move files older than the x days

Q: I want to make a file filter-> regex filter able to move files older than the current date -n to another folder.

The files i question are named like this: hjernetrim-quiz-helside_2025-01-28.pdf (hjernetrim-quiz-helside_yyyy-mm-dd.pdf)

I can’t figure out how to use the regex Filter. I have no luck with this: hjernetrim-quiz-helside_TCD:[IncDay-5]yyyy-mm-dd:
Can you help me finding the correct filter syntax?
A: In this case we are going to strip the date part from the filename and convert it to a Date. Afterwards we’ll compare this with the current date and when older than 5 days we’ll allow the file to be moved. We are not going to use a file filter for this but instead use a little script.
  • First setup your Source, we used a Windows folder as Source:
limagito file mover windows folder as source
  • Open our Pascal Script option:
limagito file mover pascal script option
  • Enable and add the following ‘On Destination’ script:  link
    • You can adjust the ctOlderThanDays Const if needed. At the moment it is set to 5
limagito file mover strip date from filename
  • As Destination we used a Windows Folder:

limagito file mover windows folder as destination

  • RunTime Log Result:

limagito file mover runtime log result

If you need any help with this “strip date from filename filter”, please let us know.

Best Regards,

Limagito Team

#managedfiletransfer #filetransfer #filemanagement

SEARCH