Any quick way to delete files while excluding some?.
Thanks....
Far to little info to give a good answer...there is, of course, FileDelete(). You might take a look at the FileSearch Extender. Without knowing what you want to do can't offer much more.
Jim
Delete everything in a folder structure minus a specific type of file ....
If you are needing to traverse directories then the FileSearch Extender is probably your best bet. You can retrieve a list of the files, excluding the ones you want to exclude, and then delete them. If only specific file types reside within the structure then you could work with directories and file types, still using the Extender, perhaps but if that is an unknown then file by file should do the trick.
Jim
Quote from: morenos1 on January 08, 2015, 07:09:24 AM
Delete everything in a folder structure minus a specific type of file ....
AddExtender("wwfaf44i.dll")
strPath = "c:\projects\foldersearch\test\Clean"
lExclude = 'log|wbt' ; Don't delete files with these extensions.
nCnt = 0
fsHandle = fafOpen(strpath, "*.*", 16) ; 16 = do sub directories.
While @TRUE
strFound = fafFind(fsHandle)
If strFound == "" Then Break
if !ItemLocate(FileExtension(strfound),lEcxlude, '|')
nMode = ErrorMode(@Off)
FileDelete(strFound)
ErrorMode(nMode)
if LastError() then Pause("Delete Failed", strFound)
else nCnt+=1
endif
EndWhile
:cancel
fafClose(fsHandle)
Message('Done', nCnt:' file(s) deleted')
Thank You. This will work ......