Sign in to follow this  
Followers 0
d4rk

Identify a species file's type

13 posts in this topic

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

Share this post


Link to post
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


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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

It works with .doc for me.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
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

Share this post


Link to post
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.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
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


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

For your filedelete line try this

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

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



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0