File Mover Blog

May 28, 2023

Delete all contents of a destination folder before files are moved

Q: Is there a way to delete all contents of a destination folder before files are moved/not just overwriting them? I am unzipping a large folder with files daily, most files are named the same thing so they can overwrite them. Have a few that are named with dates and times so they just end up staying in the folder.

A: If the unzip folder is always the same, the following solution could help you. We added a script that will delete all files and subfolders when ‘On Rule Begin’ is triggered. The path you need to use in the script is the one you will use in your UNZIP as Destination setup.

– Open Pascal Script Setup

limagito file mover pascal script

  • Enable and Add the following ‘On Rule Begin’ Pascal Script. In this example our Unzip path = C:\Test\Out\UNZIP\

Don’t forget to adjust the ctOutputPath const, must end with a \

  ctOutputPath = 'C:\Test\Out\UNZIP\';
  psExitCode:= 1;
  // ... add your code here
  psLogWrite(1, '', 'Delete Tree: ' + ctOutputPath);
  psDeleteFiles(ctOutputPath, '*.*');
  psDeleteTree(ctOutputPath, True);

Delete all contents of a destination

#filetransfer #mft #filemanagement

If you need any info  about this ‘Delete all contents of a destination’ request, please let us know.

Best regards,

Limagito Team

By Limagito-Team Pascal Script WIN ZIP , Share: