Jump to content
Sign in to follow this  
Herm

Delete all files with Attribute Archive is Off

Recommended Posts

Herm

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?

Share this post


Link to post
Share on other sites
ChrisL

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

Share this post


Link to post
Share on other sites
ChrisL

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.