Jump to content

Identify a species file's type


d4rk
 Share

Recommended Posts

2, can i use some codes to find all the .doc file on my pc ?

i've tried and success on one or some Dir which was targeted manually

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

I have no idea who wrote this but it works

; _FileSearch( <Path and Mask>, <Option (0 - normal, 1- recursive)>)
; Returns array. Either Array of files (full path) where...
; Array[0] is number of files.
; Array[0] = 0 if nothing found.
;
; EXAMPLE USAGE
;--------------------------------------------
$a = _FileSearch("*.au3",1)
If $a[0] > 0 Then
    For $i = 1 to $a[0]
         MsgBox(4096,"Files Found",$a[$i])
    Next
EndIf
;--------------------------------------------

Func _FileSearch($szMask,$nOption)
    $szRoot = ""
    $hFile = 0
    $szBuffer = ""
    $szReturn = ""
    $szPathList = "*"
    Dim $aNULL[1]

    If Not StringInStr($szMask,"\") Then
         $szRoot = "c:\"
    Else
         While StringInStr($szMask,"\")
              $szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\"))
              $szMask = StringTrimLeft($szMask,StringInStr($szMask,"\"))
         Wend
    EndIf
    If $nOption = 0 Then
         _FileSearchUtil($szRoot, $szMask, $szReturn)
    Else
         While 1
              $hFile = FileFindFirstFile($szRoot & "*.*")
              If $hFile >= 0 Then
                   $szBuffer = FileFindNextFile($hFile)
                   While Not @ERROR
                        If $szBuffer <> "." And $szBuffer <> ".." And _
                             StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _
                             $szPathList = $szPathList & $szRoot & $szBuffer & "*"
                        $szBuffer = FileFindNextFile($hFile)
                   Wend
                   FileClose($hFile)
              EndIf
              _FileSearchUtil($szRoot, $szMask, $szReturn)
              If $szPathList == "*" Then ExitLoop
              $szPathList = StringTrimLeft($szPathList,1)
              $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\"
              $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1)
         Wend
    EndIf
    If $szReturn = "" Then
         $aNULL[0] = 0
         Return $aNULL
    Else
         Return StringSplit(StringTrimRight($szReturn,1),"*")
    EndIf
EndFunc

Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN)
    $hFile = FileFindFirstFile($ROOT & $MASK)
    If $hFile >= 0 Then
         $szBuffer = FileFindNextFile($hFile)
         While Not @ERROR
              If $szBuffer <> "." And $szBuffer <> ".." Then _
                   $RETURN = $RETURN & $ROOT & $szBuffer & "*"
              $szBuffer = FileFindNextFile($hFile)
         Wend
         FileClose($hFile)
    EndIf
EndFunc


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Thanks, that what i'm looking for :)

also to the author of it

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

2, :) i need a little help with this useful code ....

; _FileSearch( <Path and Mask>, <Option (0 - normal, 1- recursive)>)

; Returns array. Either Array of files (full path) where...

; Array[0] is number of files.

; Array[0] = 0 if nothing found.

;

; EXAMPLE USAGE

;--------------------------------------------

$a = _FileSearch("*.doc",1)

If $a[0] > 0 Then

For $i = 1 to $a[0]

;MsgBox(4096,"Files Found",$a[$i])

filedelete($a[$i]) ; when i change to this, the program doesn't delete the .doc file, i don't know but when display in a message box (as the italic line), it show the full path ?

Next

EndIf

;--------------------------------------------

Func _FileSearch($szMask,$nOption)

$szRoot = ""

$hFile = 0

$szBuffer = ""

$szReturn = ""

$szPathList = "*"

Dim $aNULL[1]

If Not StringInStr($szMask,"\") Then

$szRoot = "c:\"

Else

While StringInStr($szMask,"\")

$szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\"))

$szMask = StringTrimLeft($szMask,StringInStr($szMask,"\"))

Wend

EndIf

If $nOption = 0 Then

_FileSearchUtil($szRoot, $szMask, $szReturn)

Else

While 1

$hFile = FileFindFirstFile($szRoot & "*.*")

If $hFile >= 0 Then

$szBuffer = FileFindNextFile($hFile)

While Not @ERROR

If $szBuffer <> "." And $szBuffer <> ".." And _

StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _

$szPathList = $szPathList & $szRoot & $szBuffer & "*"

$szBuffer = FileFindNextFile($hFile)

Wend

FileClose($hFile)

EndIf

_FileSearchUtil($szRoot, $szMask, $szReturn)

If $szPathList == "*" Then ExitLoop

$szPathList = StringTrimLeft($szPathList,1)

$szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\"

$szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1)

Wend

EndIf

If $szReturn = "" Then

$aNULL[0] = 0

Return $aNULL

Else

Return StringSplit(StringTrimRight($szReturn,1),"*")

EndIf

EndFunc

Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN)

$hFile = FileFindFirstFile($ROOT & $MASK)

If $hFile >= 0 Then

$szBuffer = FileFindNextFile($hFile)

While Not @ERROR

If $szBuffer <> "." And $szBuffer <> ".." Then _

$RETURN = $RETURN & $ROOT & $szBuffer & "*"

$szBuffer = FileFindNextFile($hFile)

Wend

FileClose($hFile)

EndIf

EndFunc

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

I have no idea who wrote this but it works

and many others. I do not recognize this offering.

There has been Larry. Ezzetabi, Jos, Gary Frost and some others do a filesearch UDF by memory.

Search for "filesearch" will reap results.

Link to comment
Share on other sites

these codes can't find *.doc file but it works with *.txt , why ?

Edited by d4rk

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

these codes can't find *.doc file but it works with *.txt , why ?

It works with .doc for me.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

is it work on all drive ?

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

is it work on all drive ?

If you study the code you will see that it is set to work on c:\. You can change it to work on any drive you choose.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

If you study the code you will see that it is set to work on c:\. You can change it to work on any drive you choose.

Wait a sec ....

i change to d:\ where my doc file are store and it works :)

but at first with C:\ when i try a .au3 or txt file, it even find some on E drive

maybe there's a connection between C & E ?

Edited by d4rk

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

Try this

; _FileSearch( <Path and Mask>, <Option (0 - normal, 1- recursive)>)
; Returns array. Either Array of files (full path) where...
; Array[0] is number of files.
; Array[0] = 0 if nothing found.
;
; EXAMPLE USAGE
;--------------------------------------------
$a = _FileSearch("*.doc",1)
If $a[0] > 0 Then
    For $i = 1 to $a[0]
         MsgBox(4096,"Files Found",'"' & $a[$i] & '"')
    Next
EndIf
;--------------------------------------------

Func _FileSearch($szMask,$nOption)
    $szRoot = ""
    $hFile = 0
    $szBuffer = ""
    $szReturn = ""
    $szPathList = "*"
    Dim $aNULL[1]

    If Not StringInStr($szMask,"\") Then
         $szRoot = "d:\"
    Else
         While StringInStr($szMask,"\")
              $szRoot = $szRoot & StringLeft($szMask,StringInStr($szMask,"\"))
              $szMask = StringTrimLeft($szMask,StringInStr($szMask,"\"))
         Wend
    EndIf
    If $nOption = 0 Then
         _FileSearchUtil($szRoot, $szMask, $szReturn)
    Else
         While 1
              $hFile = FileFindFirstFile($szRoot & "*.*")
              If $hFile >= 0 Then
                   $szBuffer = FileFindNextFile($hFile)
                   While Not @ERROR
                        If $szBuffer <> "." And $szBuffer <> ".." And _
                             StringInStr(FileGetAttrib($szRoot & $szBuffer),"D") Then _
                             $szPathList = $szPathList & $szRoot & $szBuffer & "*"
                        $szBuffer = FileFindNextFile($hFile)
                   Wend
                   FileClose($hFile)
              EndIf
              _FileSearchUtil($szRoot, $szMask, $szReturn)
              If $szPathList == "*" Then ExitLoop
              $szPathList = StringTrimLeft($szPathList,1)
              $szRoot = StringLeft($szPathList,StringInStr($szPathList,"*")-1) & "\"
              $szPathList = StringTrimLeft($szPathList,StringInStr($szPathList,"*")-1)
         Wend
    EndIf
    If $szReturn = "" Then
         $aNULL[0] = 0
         Return $aNULL
    Else
         Return StringSplit(StringTrimRight($szReturn,1),"*")
    EndIf
EndFunc

Func _FileSearchUtil(ByRef $ROOT, ByRef $MASK, ByRef $RETURN)
    $hFile = FileFindFirstFile($ROOT & $MASK)
    If $hFile >= 0 Then
         $szBuffer = FileFindNextFile($hFile)
         While Not @ERROR
              If $szBuffer <> "." And $szBuffer <> ".." Then _
                   $RETURN = $RETURN & $ROOT & $szBuffer & "*"
              $szBuffer = FileFindNextFile($hFile)
         Wend
         FileClose($hFile)
    EndIf
EndFunc


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

For your filedelete line try this

filedelete('"' & $a[$i] & '"')

Please be sure that you really want to delete the files.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

your code works , but only in D drive, where my doc file store, i have 1 doc at D & 1 at E, but it can't find doc file in E

But thanks for your help, i think it's enough for me, i will handle the other part my self ....

thanks again

Edited by d4rk

[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...