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](https://limagito.com/wp-content/uploads/Image-and-sidecar-xml.04.png)
- 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 \
Const
ctOutputPath = 'C:\Test\Out\UNZIP\';
Begin
psExitCode:= 1;
// ... add your code here
psLogWrite(1, '', 'Delete Tree: ' + ctOutputPath);
psDeleteFiles(ctOutputPath, '*.*');
psDeleteTree(ctOutputPath, True);
End.
![Delete all contents of a destination](https://limagito.com/wp-content/uploads/Delete-all-contents-of-a-destination.01.png)
#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