Jump to content

Spaces in Environment Variables


Recommended Posts

Hi everybody,

first of all: i'm new to this, so please be gentle :">

I'm trying to write a script that puts the content of "dir /b" to an array, but i can't figure out how exactly the syntax has to be when i'm using @Userprofiledir because it's got spaces whithin.

I'm doing this with a detour over a file that is then read into the array.

This is my code:

#include <file.au3>
#include <Array.au3>


RUNWAIT(@COMSPEC & " /k dir "& @userprofiledir &" > c:\temp\userprofiles.log")
DIM $userprofiles
_FileReadToArray("C:\temp\userprofiles.log",$userprofiles)
FILEDELETE("c:\temp\userprofiles.log")
_ArrayDisplay($userprofiles, "lala")
_ArrayPop($userprofiles)
_ArrayReverse($userprofiles)
_ArrayPop($userprofiles)
_ArrayReverse($userprofiles)

It keeps telling me that the file does not exist.

Thanks in advance,

b1ff

Link to comment
Share on other sites

If you use Beta version you can use _FileListToArray

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray(@userprofiledir)
If (Not IsArray($FileList)) and (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")


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 use Beta version you can use _FileListToArray

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray(@userprofiledir)
If (Not IsArray($FileList)) and (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")
Great, thanks für the fast answer, I'll check that out.

But anyway, how would the syntax be?

Thanks,

b1ff

Link to comment
Share on other sites

Does c:\temp exist? It fails for me as I do not have c:\temp. If I create c:\temp, then it works fine.

I duno't know what went wrong before, but it really seems to work now! :) THANKS!!

c:\temp dir exist anyway.

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