|
Post by milfredo on May 12, 2019 20:01:43 GMT -5
I would like to write a piece of code to look into a folder and delete all files that do not have the extension that I want in the folder. Anybody help?
Thanks
Milfredo
|
|
|
Post by mknarr on May 13, 2019 8:26:58 GMT -5
I just happened to have this code in another program.
nomainwin dim filearray$(20),info$(10,10) [deletefile] 'Delete file. WindowWidth = 300 WindowHeight = 400 listbox #deletefile.lb1, filearray$(, [deleteselect],20, 10, 260, 300 open "Load an existing file" for window as #deletefile
#deletefile, "font arial 10 bold" #deletefile, "trapclose [quitdeletefile]" #deletefile.lb1, "singleclickselect" files DefaultDir$,"*.",info$() if val(info$(0,0))<1 then Notice "Notice!"+chr$(13)+"There are no saved files" close #deletefile wait else redim filearray$(20) for x=1 to val(info$(0,0)) filearray$(x)=info$(x,0) next end if #deletefile.lb1, "reload" wait
[deleteselect] 'Delete the file. #deletefile.lb1, "selection? filename$" Confirm "Are you sure you want to delete file "+filename$;ans$ if ans$="yes" then kill filename$ 'Fall through
[quitdeletefile] close #deletefile end
All you do is click on the file and it will be deleted. I didn't know if the line files DefaultDir$,"*.",info$() would work without an extension but I changed a file to remove the extension and it found it and deleted it.
|
|
|
Post by milfredo on May 13, 2019 12:42:04 GMT -5
Thank you so much. I'll give it a try.
|
|