marty Professional Member
Joined: 10 May 2001 Posts: 789
|
Posted: Tue Jun 04, 2002 4:24 pm Post subject: Drag n Drop folder and filter out specific file types |
|
|
Hi,
This piece of code was done completly by LiquidCode (Thanks to him by the way). All credits goes to him of course...
Enjoy!
Code: | rem This code lets you Drag and Drop a folder (just one but it
rem can easily be modified for more than one) and list all
rem the directories and files within that folder. It also
rem has a file filter to filter out a specific file (only one
rem file type can be filtered, but it can be modified for more
rem than one type)
title Drag and Drop Folder - by Chris Gingerich
dialog CREATE,Drag and Drop Folder - by Chris Gingerich,-1,0,349,286,DRAGDROP
dialog ADD,LIST,LIST1,29,8,330,244
dialog ADD,TEXT,TEXT1,4,10,108,13,Drag and Drop a folder
dialog ADD,TEXT,TEXT2,6,160,44,13,File Filter:
dialog ADD,EDIT,EDIT1,4,208,100,19,*.*
dialog SHOW
:evloop
wait event
goto @event()
:close
stop
:dragdrop
list create,1
list dropfiles,1
%%dir = @item(1)
list close,1
if @dlgtext(edit1)
%%filter = @dlgtext(edit1)
else
%%filter = *.*
end
list clear,list1
gosub Dirs
gosub Files
goto evloop
:Dirs
if %%dir
list CREATE,1
list CREATE,2
list CREATE,3,SORTED
list FILELIST,1,%%dir*.*,D
if @greater(@count(1),0)
%x = 0
repeat
list CLEAR,2
list FILELIST,2,@item(1,%x)\*.*,D
if @greater(@count(2),0)
%%x2 = 0
repeat
list ADD,1,@item(2,%%x2)
%%x2 = @succ(%%x2)
until @equal(%%x2,@count(2))
end
%x = @succ(%x)
until @equal(%x,@count(1))
else
list ADD,1,%%dir
end
list ASSIGN,3,1
list CLOSE,1
list CLOSE,2
end
exit
:Files
if @greater(@count(3),0)
list CREATE,1
list CREATE,2,SORTED
%c = @count(3)
%x = 0
repeat
list CLEAR,2
list FILELIST,2,@item(3,%x)"\"%%filter
if @greater(@count(2), 0)
%%x2 = 0
repeat
list ADD,1,@item(2,%%x2)
%%x2 = @succ(%%x2)
until @equal(%%x2, @count(2))
rem ** Unremark the next 2 lines to have the Dirs listed as well **
rem else
rem list ADD,1,@item(3,%x)
rem ***************************************************************
end
%x = @succ(%x)
until @equal(%x,%c)
list ASSIGN,3,1
list CLOSE,1
list CLOSE,2
list assign,list1,3
end
list close,3
exit |
|
|