4 Replies Latest reply on Jun 7, 2018 4:36 PM by Steven Dod

    ePDM Dispatch: Delete files older than {timespan}

    Knut Köhlert

      Maybe someone has worked on this task. I want to delete all files in a folder that are older than two weeks. My approach is to check the creation time of the file and the current time and if the difference is greater than two weeks, delete it.

      Is that possible?

        • Re: ePDM Dispatch: Delete files older than {timespan}
          Prasad Bhonsule

          You can definitely get the time when the file was created as a Dispatch variable, and the time when the current file was modified. However, I'm not sure how this reports out, and whether you'd be able to subtract between the two.

           

          You may be better off running a search between date ranges every few weeks and deleting as required.

          • Re: ePDM Dispatch: Delete files older than {timespan}
            Martin Solem

            I think i remember from a previous request, working with dates in Dispatch (or in a data card for that matter) will not work because it recognizes the date as a number, and subtraction will almost never give you a correct result. Especially if your date span includes the end of a month and beginning of the next. In my case playing with dates and subtraction in data card (norwegian standard date dd.mm.yyyy):

             

            Created: 14.10.2015

            Modified: 28.10.2015

            Age: 14

             

            All good so far, then:

            Created: 14.10.2015

            Modified: 01.11.2015

            Age: -12.99

             

            Created: 14.10.2015

            Modified: 15.10.2018

            Age: 1

             

            So it recognizes the day and month as a number with 2 decimals, and then just subtracts.

            Switch to US standard (mm.dd.yyyy):

             

            Created: 10.14.2015

            Modified: 11.01.2015

            Age:0.87

            • Re: ePDM Dispatch: Delete files older than {timespan}
              Joy Garon

              Hello,

               

              There is not enough detail that describes what you are trying to do.

              Are the file in a 'private state' (eg: added to the vault but not checked in?)

              Are they checked in?

              What do you want to happen if the files have references?

              Do you want 'delete' or 'destroy'?

               

              Regardless of the answers to the above questions, Dispatch is the wrong tool for this - in my opinion :-).

              It lacks date functions and error trapping.

              You need to perform date functions which are best done with T-SQL which can then be put into a report if desired.

              But, ultimately, you may need to use the API to handle decision logic.

               

              Here is a sample report that shows how to use date difference functions to find how long documents have been in a state.

               

              Regards,

              Joy

              • Re: ePDM Dispatch: Delete files older than {timespan}
                Steven Dod

                You could look at the Cold Storage function in the PDM Administration tool.  It has the ability to delete the files as well as moving them to another location.