forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help me code find files

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
MondoNuovo
Valued Newbie


Joined: 09 Jul 2001
Posts: 44
Location: Italy

PostPosted: Sat Feb 16, 2002 2:20 pm    Post subject: Help me code find files Reply with quote

Crying or Very sad
Hello to all,
first of all, excused bad English!
I ask help the large ones for this forum!!

How to find files different in all drive installed in the computer in
sequenzial way and then to visualize the result in one list (pressing
a single push-button " Find ")?

Example:
find *.tmp, *.chk, *.old, *.bak etc. in all drive installed in the computer

Example result in a list:
C:\WINDOWS\file1.tmp
C:\WINDOWS\file2.tmp
C:\Temp\file3.tmp
C:\WINDOWS\file4.bak
...
C:\DOCUMENTS\file_n.old
C:\file.chk
...
D:\MyFolder1\file_x.tmp
D:\MyFolder2\SubFolder\file_y.bak
...

No problem in order to find all the drive installed in the computer, I
use the following code:

%C = 65
repeat
%S = @volinfo(@chr(%C),S)
if @ok()
list add,Drv,@chr(%C):
end
%C = @succ(%C)
until @equal(%C,90)
list seek,drv,0


But after like continuing?
I hope that someone help me.
Thanks in advance
Daniel
Back to top
View user's profile Send private message Send e-mail
rolandfg
Newbie


Joined: 30 Jan 2002
Posts: 6
Location: Italy

PostPosted: Sat Feb 16, 2002 3:34 pm    Post subject: Reply with quote

You should create a hidden list

Code:
list create,1


Then, for every drive:
1) add all drive subdirectories to the list (drivelist is the name of the list containing drives name).
2) for every item of this list add all file you want to the list in your dialog (in the example it is called list1).

Code:

%n = @count(drivelist)
rem step # 1
repeat
    list clear,1
    list filelist,1,@item(drivelist,%i)
   
    rem step # 2
    %k = @count(1)
    repeat
         directory change,@item(1,%j)
         list filelist,list1,*.tmp
         list filelist,list1,*.chk
         ...
         %j = @succ(%j)
    until @equal(%j,%K)

    %i = @succ(%i)
until @equal(%i,%n)


Note: since scanning all drive is a very long task you should find a method to show the progress of searching...

_________________
Best regards, Rolandfg

http://rolandfg.vdsworld.com
Back to top
View user's profile Send private message Visit poster's website
MondoNuovo
Valued Newbie


Joined: 09 Jul 2001
Posts: 44
Location: Italy

PostPosted: Sat Feb 16, 2002 8:00 pm    Post subject: Help me find file Reply with quote

Hi rolandfg,
you can help me?

Code:

Title Eraser
  DIALOG CREATE,Eraser file (test),-1,0,396,315
  DIALOG ADD,LIST,LB,18,8,378,144
  DIALOG ADD,combo,file,174,20,84,21
  DIALOG ADD,BUTTON,Scan,174,246,64,24,Scan,default
  DIALOG ADD,BUTTON,Delete,212,246,64,24,Delete
  DIALOG ADD,COMBO,drivelist,174,122,84,21
  dialog add,text,text1,212,10,,,Drives:
  dialog add,text,num,212,60,,,
  DIALOG ADD,BUTTON,Exit,284,324,,,Exit
  DIALOG SHOW
 
list loadtext,file
"*.tmp
"*.chk
list seek,file,0

rem ==== Search all drives =====
     dialog cursor,wait
   %C = 65
   repeat
      %S = @volinfo(@chr(%C),S)
      if @ok()
         list add,drivelist,@chr(%C):
      end
      %C = @succ(%C)
   until @equal(%C,90)
   dialog cursor
   dialog set,num,@count(drivelist)
   list seek,drivelist,0
rem ====== End search drives ======    

:Evloop
  wait event
  goto @event()
 
:ScanBUTTON
list create,1
%n = @count(drivelist)
rem step # 1
repeat
    list clear,1
    list filelist,1,@item(drivelist,%i)
    rem step # 2
    %K = @count(1)
    repeat
         directory change,@item(drivelist,%j)
         list filelist,lb,*.tmp
         list filelist,lb,*.chk
         
         %j = @succ(%j)
    until @equal(%j,%K)

    %i = @succ(%i)
until @equal(%i,%n)
  goto evloop

:DeleteBUTTON
dialog cursor,wait
list seek,LB,0
   repeat
      %F = @item(LB)
      if @not(@null(%F))
         file delete,%F
         list delete,LB
         dialog disable,Delete
      end
   until @null(%F)
   dialog clear,LB
   dialog cursor
   goto evloop

:ExitBUTTON
:Close
  exit


Thanks
Daniele
Back to top
View user's profile Send private message Send e-mail
iMPA
Newbie


Joined: 26 May 2001
Posts: 9
Location: Spain

PostPosted: Sun Feb 17, 2002 5:24 am    Post subject: Reply with quote

just restart the value of the counter...

Code:

    rem step # 2
    %K = @count(1)
    %j = 0
    repeat

_________________
share what you know, learn what you don't
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Sylvester
Valued Newbie


Joined: 31 Jul 2000
Posts: 43
Location: Boston, MA USA

PostPosted: Thu Feb 21, 2002 2:15 am    Post subject: Reply with quote

Hi MondoNuovo,

Did you figure out the answer to your question?

I tried that code you posted and it sent me on a non ending loop. Sad So I wrote a piece of code during my lunch-break earlier that will do what I think you wanted. Take a look at it and see if you will be able to use it.

It is a little long, so please bear with me. Since I have a hard time following even my own thoughts, I placed REMarks inside the code to try to make it easier for you to follow what is going through my warped mind. Rolleyes

Here is the code.

Code:

Title Eraser
  DIALOG CREATE,Eraser file (test),-1,0,447,250
  DIALOG ADD,LIST,LB,12,164,272,176
  DIALOG ADD,LIST,Files,28,8,64,124
  DIALOG ADD,LIST,Drives,28,88,64,124
  DIALOG ADD,BUTTON,ADD,164,12,56,24,Add Ext.
  DIALOG ADD,BUTTON,REFRESH,164,92,56,24,Refresh
  DIALOG ADD,BUTTON,Scan,196,184,64,24,Scan
  DIALOG ADD,BUTTON,Delete,196,272,64,24,Delete
  DIALOG ADD,BUTTON,Cancel,196,356,64,24,Cancel
  DIALOG ADD,TEXT,DRIVELABEL,12,88,64,12,Drives:
  DIALOG ADD,TEXT,FILELABEL,12,8,64,12,File Ext.
  DIALOG ADD,STATUS,STATUS
  DIALOG SHOW
REM    Add horizontal scrollbar, we like pretty scrollbars.
  %z = @sendmsg(@winexists(~LB),$0194,2000,0)
  DIALOG DISABLE,Delete
  DIALOG DISABLE,Cancel
  LIST CREATE,1
  LIST CREATE,2

REM    Our default extensions
List loadtext,Files
"*.tmp
"*.chk
REM    We assign content of Files to a hidden list to prevent our list from flashing.
List assign,2,Files

:RefreshBUTTON
REM    We made a Refresh button because it's cool!  Smile
REM -- Search/Refresh all drives --
  Dialog cursor,wait
  List clear,Drives
  %%CHR = 65
  Repeat
    %%VOL = @volinfo(@chr(%%CHR),S)
    If %%VOL
      List add,Drives,@chr(%%CHR):
    End
    %%CHR = @succ(%%CHR)
  Until @greater(%%CHR,90)
  Dialog cursor
  Dialog set,DRIVELABEL,Drives: @count(Drives)
  List seek,Drives,0
REM -- End Search/Refresh drives --
REM    No 'goto evloop' here because we are already here.

:Evloop
  Wait event
  %E = @event()
  Goto %E

:AddBUTTON
REM    A choice to add more extensions to the list.
REM    Input is checked to be sure it fits our standard.
  %%INPUT = @input(Enter the extension to add: "(Must be 3 letters)",,)
  If %%INPUT
    If @equal(@len(%%INPUT),3)
      List add,Files,*.%%INPUT
      List add,2,*.%%INPUT
    Else
      Goto AddBUTTON
    End
  End
  Goto evloop

:ScanBUTTON
REM    There are atleast 3 tiers of action going on in this Event.
REM    We have the pretty preliminaries of disabling and enabling controls.
  Dialog disable,Scan
  Dialog enable,Cancel
  Dialog focus,Cancel
  Dialog clear,status
  If @greater(@count(LB),0)
    Dialog disable,Delete
    List clear,LB
  End
REM -- Loop 1 Start Scan of Each Drives --
REM    Our 1st tier of action - Scanning the Drives.
REM    We create a list of Directories and Subdirectories.
  If @greater(@count(Drives),0)
    %%DRIVE = 0
    Repeat
REM    This is where are very busy so we change cursor to show the user we are busy.
      Dialog cursor,wait
      List clear,1
      List seek,Drives,%%DRIVE
      List add,1,@item(Drives)
REM    Create the list of Directories/Subdirectories
      List filelist,1,@item(Drives),*
REM    NOTE: Using 'LIST FILELIST,L1,\PATH,*' as we did above will find directories and
REM    subdirectories BUT it will not find any HIDDEN directories/subdirectories.
REM    You can use the ATTRIBUTE H to find hidden as in 'LIST FILELIST,L1,\PATH,*H', but
REM    this will also list hidden files along with the hidden directories.  Be careful
REM    when using with the attribute H.
      Dialog cursor
REM -- Loop 2 Start Scan of Each Directories - embedded inside Loop 1 --
REM    Our 2nd tier of action - Scanning each directories and subdirectories
REM    using the list we created already.
      If @greater(@count(1),0)
        %%DIR = 0
        Repeat
REM    We are going to play nice and let the user Cancel or even Close
          %E = @event()
REM    We capture the Event here and send it down.
          If @equal(%E,CancelBUTTON)@equal(%E,Close)
            Dialog set,status,Stopped by user.
            Goto %E
          End
          List seek,1,%%DIR
REM    We have a status bar at the bottom that shows the user we are doing something.
          Dialog set,status,@shortname(@item(1))
REM -- Loop 3 Start Scan for Files - embedded inside Loop 2 --
REM -- Our 3rd tier if action - Scanning for files with our extensions.
          If @greater(@count(2),0)
            %%EXT = 0
            Repeat
              List seek,2,%%EXT
REM    We add every file we find to the main list window (LB).
              List filelist,LB,@item(1)\@item(2)
              %%EXT = @succ(%%EXT)
            Until @equal(%%EXT,@count(2))
          End
REM -- Loop 3 End Scan Files --
          %%DIR = @succ(%%DIR)
        Until @equal(%%DIR,@count(1))
      End
REM -- Loop 2 End Scan Directories --
      %%DRIVE = @succ(%%DRIVE)
    Until @equal(%%DRIVE,@count(Drives))
  End
REM -- Loop 1 End Scan Drives --
  Dialog set,status,
:CancelBUTTON
REM    Our Cancel button event is inserted here.
REM    Why write multiple routines of the same things?  I'm too lazy.  Smile
  Dialog disable,Cancel
  Dialog enable,Scan
  If @greater(@count(LB),0)
    Dialog enable,Delete
  End
  Goto evloop

:DeleteBUTTON
REM -- This is a straightforward Loop to remove the items that are on the list from the
REM -- computer and from the list itself.
REM    Of course, we again have our fancy enables/disables and cursors and so on.
  Dialog disable,Scan
  Dialog cursor,wait
  If @greater(@count(LB),0)
    Repeat
      List seek,LB,0
      File delete,@item(LB)
      List delete,LB,@item(LB)
    Until @zero(@count(LB))
  End
  Dialog disable,Delete
  Dialog enable,Scan
  Dialog cursor
  Goto evloop

:Close
  List close,1
  List close,2
  Exit


NOTE (Repeated from the Note inside the code):
Using 'LIST FILELIST,L1,\PATH,*' as we did above will find directories and subdirectories BUT it will not find any HIDDEN directories/subdirectories. You can use the ATTRIBUTE H to find hidden as in 'LIST FILELIST,L1,\PATH,*H', but this will also list hidden files along with the hidden directories. Be careful when using with the attribute H.

I hope this helps. Smile

_________________
Sylvester

In the immortal words of the great philosopher, Homer ... "D'OH!!!" 8O


Last edited by Sylvester on Sat Feb 23, 2002 12:13 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MondoNuovo
Valued Newbie


Joined: 09 Jul 2001
Posts: 44
Location: Italy

PostPosted: Fri Feb 22, 2002 1:05 am    Post subject: Reply with quote

Hi Sylvester,

thanks 1000, You have resolved my problem!
You six truly large one!!

Hi to Daniele
Back to top
View user's profile Send private message Send e-mail
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Fri Feb 22, 2002 8:10 am    Post subject: Reply with quote

A small suggestion: Perhaps it would be a good idea to be able to remove some files from the list of scan hits so that they are not deleted.

The header could be like this:
Code:

  Title Eraser
  DIALOG CREATE,Eraser file (test),-1,0,447,250
  DIALOG ADD,LIST,LB,12,164,272,176
  DIALOG ADD,LIST,Files,28,8,64,124
  DIALOG ADD,LIST,Drives,28,88,64,124
  DIALOG ADD,BUTTON,ADD,164,12,56,24,Add Ext.
  DIALOG ADD,BUTTON,REFRESH,164,92,56,24,Refresh
  DIALOG ADD,BUTTON,Scan,196,164,64,24,Scan
  DIALOG ADD,BUTTON,Remove,196,234,64,24,Remove
  DIALOG ADD,BUTTON,Delete,196,304,64,24,Delete
  DIALOG ADD,BUTTON,Cancel,196,374,64,24,Cancel
  DIALOG ADD,TEXT,DRIVELABEL,12,88,64,12,Drives:
  DIALOG ADD,TEXT,FILELABEL,12,8,64,12,File Ext.
  DIALOG ADD,STATUS,STATUS
  DIALOG SHOW
REM    Add horizontal scrollbar, we like pretty scrollbars.
  %z = @sendmsg(@winexists(~LB),$0194,2000,0)
  DIALOG DISABLE,Delete
  DIALOG DISABLE,Cancel
  DIALOG DISABLE,Remove
  LIST CREATE,1
  LIST CREATE,2


Then add this routine:
Code:

:RemoveBUTTON
  DIALOG CLEARSEL,LB
  goto evloop


and this line to the :ScanButton routine

Code:

Dialog enable,Remove


Greetz
Dr. Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
MondoNuovo
Valued Newbie


Joined: 09 Jul 2001
Posts: 44
Location: Italy

PostPosted: Fri Feb 22, 2002 12:45 pm    Post subject: Reply with quote

Thanks Dr. Dread
for yours suggestion Very Happy

Daniele
Back to top
View user's profile Send private message Send e-mail
Sylvester
Valued Newbie


Joined: 31 Jul 2000
Posts: 43
Location: Boston, MA USA

PostPosted: Fri Feb 22, 2002 4:09 pm    Post subject: Reply with quote

To Dr. Dread:
Dr. Dread you are so cool. Laughing I didn't even think about removing some unwanted things from that list. heh But I have an excuse, I wrote that during my lunch break, I was eating lunch at the same time. Razz


To Daniele:
Uh.. you are quite welcome. Smile
What does "You six truly large one!!" mean?
LOL, I know your english is not very good and I am not trying to make fun of you. I am just curious as to what that expression meant. I have never heard it before. Wink

_________________
Sylvester

In the immortal words of the great philosopher, Homer ... "D'OH!!!" 8O
Back to top
View user's profile Send private message Send e-mail MSN Messenger
MondoNuovo
Valued Newbie


Joined: 09 Jul 2001
Posts: 44
Location: Italy

PostPosted: Sat Feb 23, 2002 12:31 am    Post subject: Reply with quote

To Sylvester:

I Want to say that you to be competent and that your help has fundamental.
Very Happy
To Me a day would appeal to to visit the America!!
Sad
Hi Sylvester to Daniele (Italy)
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group