Ulysses
Ulysses

Reputation: 6015

Tcl: Directory deletion - how to ignore files that cannot be deleted

Deletion of a directory created problems if files are in use

(SETUP) 13 % file delete -force -- $env(TMP)
error deleting "../Temp\abcd": permission denied

Is there an option that allows ignoring files/dirs that show deletion violation? I don't mind if some files / dirs are not deleted as long as I am cleaning up bulk of temp files.

Upvotes: 0

Views: 403

Answers (1)

Brad Lanam
Brad Lanam

Reputation: 5723

You can wrap the file delete in a catch statement:

catch { file delete -force -- $env(TMP) }

I hope you never run this as root. Deleting your /tmp directory would be a bad thing.

References: catch

Upvotes: 1

Related Questions