Archiving

  • 03 Oct

    Looking for a File Mover Software to accomplish Archiving task

    Q: Looking for Software to accomplish Archiving task.

    Details: Looking for product that we can schedule to look at multiple project folders within a base directory, if no files have been modified in X days within a project folder, then move (copy/delete) that whole project directory and files to another server/CIFS location. Even better if that product can append a string (like date) to the moved project folder for reference ( if possible append 10_02_2020 to end of projectX folder name). Essentially we want to automate archiving data from expensive location/storage to cheap location/storage.

    A: In version v2020.10.3.0 we added some Pascal Script functions to achieve this request.

    What we will do is:
    – Scan base directory for project folders (1 level deep) using Pascal Script
    – Scan each project folder we found for the youngest filedate
    – If youngest filedate in this folder is older than x days then we add this folder to a parameter (%VSA)
    – At the end we provide this parameter (%VSA) as WIN Source. This parameter can containe multiple project folders.
    – The renaming of the Destination will be done in the WIN Destination Setup with a little help of Pascal Script

    Some screenshots to get you started:

    >Please Select WIN as Source and change the ‘Select Directory’ to %VSA.

    So as you see the WIN as Source will NOT be your project base folder! Parameters in LimagitoX File Mover start with %. %VSA stands for Variable String A. %VSA can be used at different places in the rule setup. In this case %VSA will get its value using Pascal Script.


    LimagitoX File Mover WIN as Source

    > Select ‘Pascal Script’ Setup in the ‘Moving Rule’ menu:

    LimagitoX Pascal Script

    >Enable and add the following ‘On Rule Begin’ Pascal Script:

    Important, change the following Const in the Pascal Script:

    • ctSourcePath = ‘C:\Test\In\’;
    • ctOlderThanInDays = 1000;

    ctSourcePath is the base directory of your Project Folders.

    ctOlderThanInDays is set to 1000. So in this case the youngest file should be older then 1000 days before we move the project folder and its content.

    Var
      iPath: Integer;
      tmpFileDate: TDateTime;
      tmpFileName: String;
      tmpPath: String;
      tmpPaths: TStringList;
    Const
      ctSourcePath = 'C:\Test\In\';
      ctOlderThanInDays = 1000;
    Begin
      // Init Var
      psExitCode:= 0;
      psVSA := '';
      // ... add your code here
      psLogWrite(1, '', 'PS Source File Path: ' + ctSourcePath);
      tmpPaths := TStringList.Create;
      Try
        // psListPaths(Directory: String; DirectoryFilter: String; DirectoryLevel: integer; Var Paths: TStringList);
        psListPaths(ctSourcePath, '*', 1, tmpPaths);
        psLogWrite(1, '', 'PS Folders Found: ' + tmpPaths.Text);
        // Iterate
        For iPath := 0 To (tmpPaths.Count-1) Do
        Begin
          tmpPath := tmpPaths.Strings[iPath];
          // psGetYoungestFilename(Directory: String; FilenameFilter: String; IncludeSubDirectory: boolean): String;
          tmpFileDate := psGetYoungestFileDate(tmpPath, '*.*', True);
          If tmpFileDate <> 0 Then
          Begin
            // Debug Info
            tmpFileName := psGetYoungestFilename(tmpPath, '*.*', True);
            psLogWrite(1, '', 'PS Youngest Filename Found: ' + tmpFileName + ' in ' + tmpPath);
            // Check Date
            If tmpFileDate < (Now - ctOlderThanInDays) Then
            Begin
              // Add Patht to psVSA Param
              If psVSA = '' Then
                psVSA := tmpPath + ';'
              Else
                psVSA := psVSA + tmpPath + ';';
            End;
          End;
        End;
        // Debug Info
        psLogWrite(1, '', 'PS Path Count: ' + IntToStr(tmpPaths.Count));
      Finally
        tmpPaths.Free;
      End;
      // Check Result
      If psVSA <> '' Then
      Begin
        psLogWrite(1, '', 'Pascal Script psVSA Result: ' + psVSA);
        psExitCode := 1;
      End
      Else
        psVSA := 'C:\NonExistingPath\';
    End.

    >Enable and add the following ‘On Destination’ Pascal Script

    Important, change the following Const in the Pascal Script:

    • ctSourcePath = ‘C:\Test\In\’;

    ctSourcePath is the base directory of your Project Folders. Must be exactly the same as in the previous ‘On Rule Begin’ Pascal Script.

    This Pascal Script will strip the root part of the Project Folder and set it to %VSB. We’ll use %VSB later for adding the date as requested to the root folder of the project.

    LimagitoX Pascal Script On Destination

    Const
      ctSourcePath = 'C:\Test\In\';
    Begin
      psExitCode:= 1;
      // ... add your code here
      psVSB := psStringReplace(psSourcePath, ctSourcePath, '');
      psVSB := psStringReplace(psVSB, '\', '');
      psLogWrite(1, '', 'psVSB: ' + psVSB);
    End.

    >Select ‘Add WIN’ in the Destination Setup:

    LimagitoX File Mover Select Destination

    >Select your Destination folder (= where to move the project folders to):

    LimagitoX File Mover WIN as Destination

    >Enable and set ‘Create Subdir, opt.’ to:  %VSB_%TCD:MM_DD_YYYY:\%SFS

    LimagitoX File Mover Subdir option

    > Function setup, please leave the Function to ‘Copy Files’ during your tests. If everything is ok then you can change it to ‘Move Files’.

    LimagitoX File Mover Function Setup

    > Done

    If you need any help with this Archiving task setup, please let us know.

    Best Regards,

    Limagito Team

SEARCH