Using day of the week folders
Q: I would like to sort my files based on the filename. The first 8 char contain the date that has to be used. The format is YYYYMMDD (Year = 4 char, Month = 2 char and Day 2 = char).
A: This is possible using our Pascal Script option. We’ve attached some screenshots to get you started.
- We used a Windows folder as Source:

- File Filter Setup:

- Open our Pascal Script option:

- Enable and add the following ‘On Destination’ script:
- The script will strip the date part from the filename and will check the day of the week
- Corresponding day of the week will go into the %VSA (Var String A) parameter which will be used in the Destination setup
- The script will strip the date part from the filename and will check the day of the week
Var tmpStr: String; tmpDate: TDateTime; tmpDays: array[1..7] of string; Const ctDateFormat = 'YYYYMMDD'; ctDateFormatLen = 8; ctDateSeparator = #0; Begin tmpDays[1] := 'Monday'; tmpDays[2] := 'Tuesday'; tmpDays[3] := 'Wednesday'; tmpDays[4] := 'Thursday'; tmpDays[5] := 'Friday'; tmpDays[6] := 'Saturday'; tmpDays[7] := 'Sunday'; // Default Result = Skip File psExitCode:= 0; psVSA := ''; // ... add your code here tmpStr := Copy(psFileName, 1, ctDateFormatLen); If StrToIntDef(tmpStr, -1) <> -1 Then Begin Try tmpDate := psStrToDate(tmpStr, ctDateFormat, ctDateSeparator); psVSA := tmpDays[DayOfTheWeek(tmpDate)]; // Successful Result psExitCode := 1; // Debug psLogWrite(1, '', psFileName + ' will go into subfolder: ' + psVSA); Except psLogWrite(1, '', psFileName + ' conversion exception of date part, file will be skipped'); End; End Else Begin psLogWrite(1, '', psFileName + ' does not start with a valid date, file will be skipped'); End; End.

- Destination Setup:

- Important, adjust the default ‘Create Subdir option’, add %VSA (%VSA contains the day of the week):

- RunTime Log Result:

If you need any help about this ‘day of the week folders’ option, please let us know.
Best Regards,
Limagito Team
#managedfiletransfer #filetransfer #filemanagement #limagito
