Jump to content

Not sure if this can be done as I don't know how


Recommended Posts

How would i do a input box so i can pick what I want to search for ?

DirCreate("C:\list1")
Run(@comspec& " /c dir *.dll /s >c:\list1\dlllist.txt","c:\",@SW_HIDE)

This works good now but i will have to make a bunch and would be nice to just say search for jpg's or dll's etc.

Link to comment
Share on other sites

well just one time asking what extension would be fine I think .

Then If I need it again just run it again .all rename the txt file before i run it again. lol

Unless you can input what to save the txt file as ?

Edited by bobheart
Link to comment
Share on other sites

Here it is:

DirCreate("C:\list1")
$Extension = InputBox("List Files","Please enter the extension of the files you want to list." & @CRLF & _
"(Without a dot)", "", "", 350, -1)
Run(@comspec& " /c dir *." & $Extension & " /s >c:\list1\dlllist.txt","c:\",@SW_HIDE)
Edited by SlimShady
Link to comment
Share on other sites

Can you kind of tell me how you added the part where they can input what they want to search so Maybe can do it my self ?

Thank you btw ..

Edited by bobheart
Link to comment
Share on other sites

I commented the script. Here it is:

DirCreate("C:\list1"); <------- Create Directory
; The 2 lines below are for the inputbox. What the user enters is saved as $Extension
$Extension = InputBox("List Files","Please enter the extension of the files you want to list." & @CRLF & _
"(Without a dot)", "", "", 350, -1)
;This line below runs a command with the user input: $Extension
Run(@comspec& " /c dir *." & $Extension & " /s >c:\list1\dlllist.txt","c:\",@SW_HIDE)
Link to comment
Share on other sites

Well what the hell ?

Trying the same code on my D: drive and it won't do anything ?

DirCreate("C:\list1")
$Extension = InputBox("List Files","Please enter the extension of the files you want to list." & @CRLF & _
"(Without a dot)", "txt", "", 350, -1)
Run(@comspec& " /D dir *." & $Extension & " /s >c:\list1\list.txt","D:\",@SW_HIDE)

what did I do wrong this time ?

Link to comment
Share on other sites

  • Developers

/C is part of cmd or command and the command behind it is run...

in this case Dir d:\*.*

CMD [/A | /U][/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]

    [ [/C | /K] string]

/C      Carries out the command specified by string and then terminates

/K      Carries out the command specified by string but remains

/S      Modifies the treatment of string after /C or /K (see below)

/Q      Turns echo off

/D      Disable execution of AutoRun commands from registry (see below)

/A      Causes the output of internal commands to a pipe or file to be ANSI

/U      Causes the output of internal commands to a pipe or file to be

        Unicode

/T:fg Sets the foreground/background colors (see COLOR /? for more info)

/E:ON Enable command extensions (see below)

/E:OFF  Disable command extensions (see below)

/F:ON Enable file and directory name completion characters (see below)

/F:OFF  Disable file and directory name completion characters (see below)

/V:ON Enable delayed environment variable expansion using ! as the

        delimiter. For example, /V:ON would allow !var! to expand the

        variable var at execution time.  The var syntax expands variables

        at input time, which is quite a different thing when inside of a FOR

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

How would i do a input box so i can pick what I want to search for ?

DirCreate("C:\list1")
Run(@comspec& " /c dir *.dll /s >c:\list1\dlllist.txt","c:\",@SW_HIDE)

This works good now but i will have to make a bunch and would be nice to just say search for  jpg's or dll's etc.

Larry did a function for a recursive filefindnext function

Should be faster than compiling a list. You could use a loop to change the suffix or search string

Rick

Found it

; _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,"",$a[$i])

Next

EndIf

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

Func _FileSearch($szMask,$nOption)

$szRoot = ""

$hFile = 0

$szBuffer = ""

$szReturn = ""

$szPathList = "*"

Dim $aNULL[1]

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

$szRoot = @SCRIPTDIR & "\"

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[0]

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

Edited by tutor2000

Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

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...