There are scenarios where you are required to delete files older than certain days from archive folder using Data Services. Below script will make that happen which will work on UNC paths.
Replace 10 with number of days files to be kept, you can use variable. Any files older than this will be deleted.
$GV_FILES_DELETED =FN_DOS('PushD "[$GV_ARCHIVE_DIRECTORY]" && (forfiles -s -m *.* -d -10 -c "cmd /c echo @file") & PopD'); Print( 'Files that will be deleted from Archive folder are ' || $GV_FILES_DELETED ); $GV_FILES_DELETED =FN_DOS('PushD "[$GV_ARCHIVE_DIRECTORY]" && (forfiles -s -m *.* -d -10 -c "cmd /c del /q @path") & PopD'); Print('Files Older than ' || $GV_FILE_RETENTION_DAYS || ' days are being deleted now');
FN_DOS will have following code