Jump to content

How to Search File in All drive (C~Z)


Recommended Posts

Create MiniPE to Autoload Ghost32 than search Ghost in CD

I create script Like this :

$search = FileFindFirstFile("C:\AutoRunSource\image\ImageXP.gho")

If $search = -1 Then

run("D.exe")

EndIf

While 1

$file = FileFindNextFile($search)

If @error Then ExitLoop

Run("ghost32.exe -clone,mode=pload,src=C:\AutoRunSource\image\ImageXP.gho:1,dst=1:1 -auto -sure")

ProcessWaitClose("ghost32.exe")

$PID = run("peshuteject.exe /eject:C","",@SW_HIDE)

ProgressOn("Reboot", "Remove CD From Driver..!!!", "0 percent")

For $i = 10 to 100 step 10

sleep(1000)

ProgressSet( $i, $i & " percent")

Next

ProgressSet(100 , "Done", "Reboot")

sleep(500)

ProgressOff()

run("peshuteject.exe /reboot","",@SW_HIDE)

Exit

WEnd

FileClose($search)

than create D.au3 only change drive C to drive D..

my Question..??

How to Auto search file in All drive from drive C ~ Z..??

$search = FileFindFirstFile("C~Z:\AutoRunSource\image\ImageXP.gho")

Or How to Fix my CD driver in E drive Letter..??

Link to comment
Share on other sites

  • Moderators

penggilas2,

How to Auto search file in All drive from drive C ~ Z..?? $search = FileFindFirstFile("C~Z:\AutoRunSource\image\ImageXP.gho")

Use DriveGetDrive to list the available drives. Then use a recursive file search to look through them in turn. There are lots of examples on the forums if you search. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Use DriveGetDrive to list the available drives. Then use a recursive file search to look through them in turn. There are lots of examples on the forums if you search. :)

M23

I don't think he wants a recursive file search...

Try this:

$sPath = _FindFile ("\AutoRunSource\image\ImageXP.gho")

MsgBox (0, "", $sPath)

Func _FindFile ($sPath, $sSearch = "All")
   If StringLeft ($sPath, 1) <> "\" Then $sPath = "\" & $sPath
   Local $aDrives = DriveGetDrive ($sSearch)

   For $i = 1 to $aDrives[0]
      If FileExists ($aDrives[$i] & $sPath) Then Return $aDrives[$i]
   Next
   Return SetError (1, 0, "")
EndFunc ; ==> _FindFile
Mat

Edit: If you want to search Cd Drives only use:

$sPath = _FindFile ("\AutoRunSource\image\ImageXP.gho", "CDROM")
Edited by Mat
Link to comment
Share on other sites

I don't think he wants a recursive file search...

Try this:

$sPath = _FindFile ("\AutoRunSource\image\ImageXP.gho")

MsgBox (0, "", $sPath)

Func _FindFile ($sPath, $sSearch = "All")
   If StringLeft ($sPath, 1) <> "\" Then $sPath = "\" & $sPath
   Local $aDrives = DriveGetDrive ($sSearch)

   For $i = 1 to $aDrives[0]
      If FileExists ($aDrives[$i] & $sPath) Then Return $aDrives[$i]
   Next
   Return SetError (1, 0, "")
EndFunc ; ==> _FindFile
Mat

Edit: If you want to search Cd Drives only use:

$sPath = _FindFile ("\AutoRunSource\image\ImageXP.gho", "CDROM")

Mat

I think you meant to use If StringRight($sPath, 1) <> "\" and Not StringLeft()

Tip:

Another method of making sure the path ends in a "\" is this

$sPath = StringRegExpReplace($sPath, "(?i)^([a-z]:.*?)(?:\\)*$", "$1\\")

EDIT: Slight modification to the SRE in case for some reason the original path ended in double (or more) backslashes.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Nope! completely deliberate.

C:Documents and settings\test\test.txt

is completely wrong, thats why it needs a "\" at the beginning. The end does not matter in this case.

Mat

incidently, For searching a drive / folder recursively, I've done this:

http://www.autoitscript.com/forum/index.php?showtopic=104982

Edited by Mat
Link to comment
Share on other sites

Nope! completely deliberate.

C:Documents and settings\test\test.txt

is completely wrong, thats why it needs a "\" at the beginning. The end does not matter in this case.

Mat

Okay, now I see what you were doing. Morning (brain) fog made it difficult to comprehend.

The SRE method for that is probably

$sPath = StringRegExpReplace($sPath, "(?i)(?:\\)*(.+)$", "\\$1")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Okay, now I see what you were doing. Morning (brain) fog made it difficult to comprehend.

The SRE method for that is probably

$sPath = StringRegExpReplace($sPath, "(?i)(?:\\)*(.+)$", "\\$1")

$hTimer = TimerInit ()
For $i = 1 to 100
   $sPath = "documents and settings\test\test.txt"
   $sPath = StringRegExpReplace($sPath, "(?i)(?:\\)*(.+)$", "\\$1")
Next
$nTime1 = Round (TimerDiff ($hTimer) / 100, 5)

$hTimer = TimerInit ()
For $i = 1 to 100
   $sPath = "documents and settings\test\test.txt"
   If StringLeft ($sPath, 1) <> "\" Then $sPath = "\" & $sPath
Next
$nTime2 = Round (TimerDiff ($hTimer) / 100, 5)

MsgBox (0, "results", "Time 1: " & $nTime1 & @CRLF & "Time 2: " & $nTime2)

Although the SRE is pretty, it remains slow.

Mat

Link to comment
Share on other sites

I don't think he wants a recursive file search...

Try this:

$sPath = _FindFile ("\AutoRunSource\image\ImageXP.gho")

MsgBox (0, "", $sPath)

Func _FindFile ($sPath, $sSearch = "All")
   If StringLeft ($sPath, 1) <> "\" Then $sPath = "\" & $sPath
   Local $aDrives = DriveGetDrive ($sSearch)

   For $i = 1 to $aDrives[0]
      If FileExists ($aDrives[$i] & $sPath) Then Return $aDrives[$i]
   Next
   Return SetError (1, 0, "")
EndFunc ; ==> _FindFile
Mat

Edit: If you want to search Cd Drives only use:

$sPath = _FindFile ("\AutoRunSource\image\ImageXP.gho", "CDROM")

I has try U script And found file In drive F, but I don`t know how to insert drive letter in

Run("ghost32.exe -clone,mode=pload,src= Drive Letter :\AutoRunSource\image\SalimCD.gho:1,dst=1:1 -auto -sure")

script..??

Thank`s for All..

Link to comment
Share on other sites

Run("ghost32.exe -clone,mode=pload,src=" & $sPath & "\AutoRunSource\image\SalimCD.gho:1,dst=1:1 -auto -sure")

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

A bit off topic...

$hTimer = TimerInit ()
For $i = 1 to 100
   $sPath = "documents and settings\test\test.txt"
   $sPath = StringRegExpReplace($sPath, "(?i)(?:\\)*(.+)$", "\\$1")
Next
$nTime1 = Round (TimerDiff ($hTimer) / 100, 5)

$hTimer = TimerInit ()
For $i = 1 to 100
   $sPath = "documents and settings\test\test.txt"
   If StringLeft ($sPath, 1) <> "\" Then $sPath = "\" & $sPath
Next
$nTime2 = Round (TimerDiff ($hTimer) / 100, 5)

MsgBox (0, "results", "Time 1: " & $nTime1 & @CRLF & "Time 2: " & $nTime2)

Although the SRE is pretty, it remains slow.

Mat

This is probably one of the worst speed tests I've seen be done with AutoIt.

Shows a big degree of not understanding how AutoIt works.

The results are almost completely wrong and shouldn't be considered as a proof of anything.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

  • Moderators

trancexx,

Staying off topic, why is Mat's version so wrong? I freely admit to using very similar code on several occasions - and have seen several others do the same. :)

How would you do a speed test in such a case? And what "big degree of not understanding how AutoIt works" is being displayed here? Some of us here are not as au fait with the inner workings of Autoit and/or Windows as others.

Thanks in advance for any illumination into our stygian darkness. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

trancexx,

Staying off topic, why is Mat's version so wrong? I freely admit to using very similar code on several occasions - and have seen several others do the same. :)

How would you do a speed test in such a case? And what "big degree of not understanding how AutoIt works" is being displayed here? Some of us here are not as au fait with the inner workings of Autoit and/or Windows as others.

Thanks in advance for any illumination into our stygian darkness. ;)

M23

What results you get with Mat's script when you replace the order of tests? Do StringLeft() test first.

There are people with better understanding of the subject than me. They could give you the answers, I can only speculate on the causes (not consequence though).

I would 'heat up' the engine first, before doing the speed tests.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

doing it a few extra times seems to remove that (Or at least minimize it). 100 times was not enough. As for heating it up... well, you learn something new every day, but I have never seen that done before.

Mat

Incidently... The results the same. roughly double the time for the RegEx

Edited by Mat
Link to comment
Share on other sites

I think transcexx is refering to the fact that anything involving files can be affected by file cache so it's probably better to run it several times. And I don't see time being a critical factor here anyway since it's only called the one time so you are talking fractions of a micro-second difference. There are several factors that can affect performance in a loop.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I think transcexx is refering to the fact that anything involving files can be affected by file cache so it's probably better to run it several times. And I don't see time being a critical factor here anyway since it's only called the one time so you are talking fractions of a micro-second difference. There are several factors that can affect performance in a loop.

Its not affecting files :) the computer thinks its still a string.
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...