File Mover Blog

November 1, 2021

Create subfolders ahead with Limagito File Mover

Q: We’re trying to create subfolders ahead with a rule in a following format: 2021\11 Nov21
Is it possible to do this with an empty rule eg there’s no source file to move/copy? What would be the best way to handle this? Many thanks

A: This is possible using our ‘Pascal Script’ as Source option. In this case no source files are needed.

First add ‘Pascal Script’ as Source:

Limagito File Mover Pascal Script as Source

Add the following Pascal Script code.  Do not forget to adjust the ctPath const, end with a \

Var
  tmpSubPath: String;
Const
  ctPath = 'C:\Test\Out_PSC\';
Begin
  psExitCode:= 1;
  // Create subfolders in the following format: 2021\11 Nov21
  tmpSubPath := FormatDateTime('YYYY\DD MMMYY', Now);
  If ForceDirectories(ctPath + tmpSubPath) then
    psLogWrite(1, '', 'Create Directory: ' + ctPath + tmpSubPath + ', Successful')
  Else
    psLogWrite(1, '', 'Create Directory: ' + ctPath + tmpSubPath + ', Error')
End.

Limagito File Mover Pascal Script Code example

This script will create a single subfolder when it is triggered using the current date. Of course it can be modified so it fits your needs,  just let us know.

Limagito File Mover RunTime Log

Update, received the following question from user: Is there a way to add +1 to either month or date so I can adjust as required?

1) To add a day, replace:  tmpSubPath := FormatDateTime(‘YYYY\DD MMMYY’, Now);
by
tmpSubPath := FormatDateTime(‘YYYY\DD MMMYY’, psIncDay(Now, 1));
2) To add a month, replace: tmpSubPath := FormatDateTime(‘YYYY\DD MMMYY’, Now);
by
tmpSubPath := FormatDateTime(‘YYYY\DD MMMYY’, psIncMonth(Now, 1));

 

#FileTransfer

If you need any info about this ‘create subfolders ahead’ question, please let us know.

Best regards,

Limagito Team

By Limagito-Team Pascal Script , Share:
SEARCH