Delete files in folder

Where’s an error in this row? I need to delete all files with “req” extension in folder C:\SCOM\cert. It’s a policy relevant to a specific group of servers, which is defined by existence of such files older than 30 days in that folder.

delete {files whose (name of it contains “.req”) of folder “C:\SCOM\cert”}

Servers reporting to the policy are correct, but the action doesn’t do anything. No error is reported. Action reports as Completed, but the files are still on the servers

I suspect as your relevance is returning a plural file object, that cannot be passed to the actionscript delete command. One method you can delete multiple files would be to get the pathnames of the files then create a batch script to delete each file, eg

createfile until EOF
{("del %22" & pathname of it & "%22 /q%0a") of files whose (name of it ends with ".req") of folder "C:\SCOM\cert"}
EOF

delete delfiles.cmd
copy __createfile delfiles.cmd
waithidden delfiles.cmd
3 Likes

Thanks, seems like it’s working. I didn’t know that delete can’t work with plural variable.