Jump to content
Sign in to follow this  
erik7426

FileDelete and/or DirRemove with output

Recommended Posts

erik7426

Is it possible to use FileDelete and/or DirRemove AND have the files/folders that are deleted by these commands written to a log file.

So, if I have DirRemove(@TempDir, 1) I want to be able to capture all the files that were deleted and save it to a log.

Any help would be greatly appreciated...

Share this post


Link to post
Share on other sites
weaponx

_FileListToArray + FileDelete + _FileWriteLog

Share this post


Link to post
Share on other sites
erik7426

_FileListToArray + FileDelete + _FileWriteLog

_FileListToArray + FileDelete are no problem.

Can you give me an example of how I would use _FIleWriteLog in conjuction with those commands?

I know this can be done in DOS, just trying to make it work in AutoIt...

Edited by erik7426

Share this post


Link to post
Share on other sites
Robjong

_FileListToArray + FileDelete are no problem.

Then I guess you can get this to work :P

; .... $aArray is the file list ....
For $i = 1 To UBound($aArray) - 1 
If FileDelete($aArray[$i]) Then 
    _FileWriteLog("mylog.txt", 'Deleted file: "' & $aArray[$i] & '"')
Else
    _FileWriteLog("mylog.txt", 'Unable to delete file: "' & $aArray[$i] & '"')
EndIf
Next

Edit: Loop

Edited by Robjong

Share this post


Link to post
Share on other sites
weaponx

Theoretically you would want to use a recursive file search function to handle sub folders.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.