CA PPM: How to delete files with GEL

Blog Post created by Aurora_Gaimon Employee on Apr 18, 2017

In many occasion, we have the need to delete files from a file system, specially when interfacing and we don't want to leave the system full of unneeded or obsolete files. That can be easily achieved by using the java method delete().


This method returns true if the file is successfully deleted, else false.


Let's see a sample below:




1. Create a csv file and place in in a folder. In our example, I will use "c:\testFolder" and "demoFile.csv"




2. Create a simple process with a GEL script:

<gel:script xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" 

<util:file name="c:\testFolder\demoFile.csv" var="FileToBeDeleted"/>
<core:set value="${FileToBeDeleted.delete()}" var="successful"/>
<gel:log>Is file "${FileToBeDeleted}" deleted successfully? ${successful}</gel:log>




3. Execute process and review log messages printed in screen:





4. Check the folder where file was located. We can also verify file has been deleted.




Related posts:

CA PPM: How to copy files with GEL 

CA PPM: How to move files with GEL 



If you need help with GEL scripting, engage CA Services or ask questions in CA Communities.


That’s all. Thanks for reading until here. Did you like it? Please, don’t be shy and share it.