Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member185181
Active Contributor
0 Kudos

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

Labels in this area