In my script, I need to clean up some files in a directory, so I use filedelete to delete them if they exist (they may not).
I'm logging the deletions, so how can I tell if a file was actually deleted?
filedelete, %whatfile%
if(errorlevel = 0)
;log that the file was deleted
If no file was deleted, I don't want to log it.
I'm looking at the docs, but can't figure out what to do.
This seems to be the value of errorlevel
returns 0 if it deletes the file
returns 1 if there is no file
returns 0 if a wildcard is used
How to know if filedelete deleted a file?
Re: How to know if filedelete deleted a file?
FileExist is a safe bet. If you check beforehand and afterwards, then you know whether the file has been deleted.
Re: How to know if filedelete deleted a file?
SoErrorLevel is set to the number of files that failed to be deleted (if any) or 0 otherwise
Code: Select all
if (ErrorLevel == 0) {
; log success
}
Re: How to know if filedelete deleted a file?
Good point. The documentation is confusing about this, but my understanding is the ErrorLevel will still reflect the number of failed deletions. If the mask matches no files, then there are no failures.
Re: How to know if filedelete deleted a file?
Thank you all.
My Stuff: mousey; volume; ahkinfo; instantbirder; npp highlighter; Dynamic File Menu; tv - a treeview library;