Jump to content

Delete all files with Attribute Archive is Off


Recommended Posts

I want to delete all files in one folder with the Attribute Archive is Off.

1. With FileSetAttrib ( "C:\Temp\*.txt", "-A") I can set all textfiles Archive bit off.

2. After that I place new files an overwrite files in that folder.

3. After that I want to delete all files with the Archive bit is off. (old files) Other files have the Archive bit On. (new files)

I can't do that with the function FileGetAttrib()

Has someone the solution for me?

Link to comment
Share on other sites

This deletes files in a given folder that do not have te Archive attribute set

_DeleteNoneArchiveFiles ("C:\temp");replace with your search directory

Func _DeleteNoneArchiveFiles($current)
    If StringRight($current,1) = "\" then $current = StringTrimRight($current,1)
    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
        Dim $file = FileFindNextFile($search)
        If @error Or StringLen($file) < 1 Then ExitLoop
        If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") Then
            
            IF NOT StringInStr(FileGetAttrib($current & "\" & $file),"A") then FileDelete($current & "\" & $file);delete the found file without the archive attribute set
                
        EndIf
    WEnd
    FileClose($search)

EndFunc
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...