Delete Files From Directory

Hi

Could you possibly give me any ideas as to how I delete a folder/files in a specified directory within workflow.?Thanks

Estelle

Whenever you do a basic Folder Capture task, it Moves the file from the directory into the working folders, so it’s effectively been ‘deleted’ from that original location.

You can then simply pass it into a Delete output to have the file disappear for good.

Alternatively, you could run Windows Command line commands to delete the files in a given directory. You’d do this using the External Program plugin in Actions.

Lastly, you could script the entire thing using VBScript. You can certainly find plenty of examples of this online, but here’s one on Microsoft technet: https://social.technet.microsoft.com/Forums/en-US/f2cbfd46-b6cc-4595-a731-19021bf5c60d/deleting-files-and-subfolders-how-to?forum=ITCG

Hi There

Thanks for this. I have tried the VB code and if I use the direct path which is eg: M:\testfolder\2018-02-07 it work ok. However what I am trying to do is remove the folder using the system variables %y-%m-%d as below, however this doesn’t seem to work.

Const DeleteReadOnly = TRUE
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
objFSO.DeleteFile("F:\BSU1990 GP Reports\PDFS Out" + %y+ “-” + %m + “-” + %d + “*”),DeleteReadOnly

?I’m not sure where I am going wrong?

Thanks

When you’re using the Watch System Variables, or any Watch variable, you need to use Watch.ExpandString to get it into your script. Examples in the link below.

http://help.objectiflune.com/en/pres-workflow-user-guide/8.8/#Workflow/Scripts/WatchExpandString.html

That’s Brilliant Thanks! That’s me sorted :slight_smile:

Good stuff! Happy scripting!