Jump to content

Is it possible?


Recommended Posts

Also, I was wondering if anybody has come up with a function to get text that comes after something. Like finding out what it says after readrl or something.

[center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw

Link to comment
Share on other sites

There are a bunch of methods; I stayed from StringSplit since it might be inefficient; you could also use the StdIO-redirection in the beta if you wanted to use the 'dir' command.

$foo = _DirToArray(@ScriptDir)
$temp = ""
For $i = 0 to UBound($foo)-1
    $temp = $temp & $i & @TAB & $foo[$i] & @CRLF
Next
MsgBox(4096,UBound($foo) & " items", $temp)
Exit

Func _DirToArray($folder, $filters = "*.*")
    Local $dirInfo = DirGetSize($folder, 3);non-recursive extended info flag
    Local $count = $dirInfo[1] + $dirInfo[2] ;number of files and folders
    
    Local $search = FileFindFirstFile($folder & "\" & $filters)
    If $search = -1 Then
        SetError(1)
        Return 0
    EndIf
    
    Local $output[$count]
    
    Local $i = 0
    While 1
        $file = FileFindNextFile($search)
        If @error Then ExitLoop
        If $file = "." or $file = ".." Then ContinueLoop
        $output[$i] = $file
        $i = $i + 1
    Wend
    ReDim $output[$i]
    
    Return $output
EndFunc

Edit: To answer your other question, have you looked at StringInStr?

Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Here's my version if anyone was interested, although it's not nearly as cool as cyberslugs :) :

#Include <process.au3>
#include <file.au3>

$dir = "C:\"
$foo = _Foo($dir)

Func _Foo($loc)
    Local $array
    Local $file = "C:\\abc.txt"
    
    _RunDOS("dir /B " & $loc & " > " & $file)
    _FileReadToArray($file, $array)
    FileDelete($file)

    Return($array)
EndFunc
Link to comment
Share on other sites

Easy enough...

You can even use /O to sort in whatever order you'd like them to be listed.

Well that about covers that  :)

<{POST_SNAPBACK}>

if you want to do some tricks with every file or dir, try "forfiles" it's part of w2k3

i used it together with the setowner tool to get all the fileowners in a certain directory.

greetings

Kees

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