AutoHotkey Community

It is currently May 27th, 2012, 5:45 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: March 17th, 2010, 10:27 pm 
Hi, This is a very simple task for most, but difficult for me hehe:
How do i get a list of the filenames in my pc c:\temp\screenshot directory? Then save this list to c:\list.txt. I will use this list as below:

Code:
^j::
; write to the Array:
ArrayCount = 0
Loop, Read, C:\List.txt
{
    ArrayCount += 1
    Array%ArrayCount% := A_LoopReadLine
}

; read from the Array:
Loop %ArrayCount%
{
    element := Array%A_Index%
    MsgBox % "Element number " . A_Index . " is " . Array%A_Index%
}
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 17th, 2010, 10:54 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Code:
Loop,c:\temp\screenshot\*
 FileAppend,%A_LoopFileFullPath%`n,C:\List.txt

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject: thanks!
PostPosted: March 17th, 2010, 11:43 pm 
Thank you HotKeyIt. It works beautifully! Here's my final codes:

Code:
^j::

; read screenshot directory
Loop,c:\test\*
    FileAppend,%A_LoopFileFullPath%`n, C:\screenshots.txt

; write to the Array:
ArrayCount = 0
Loop, Read, C:\screenshots.txt
{
    ArrayCount += 1
    Array%ArrayCount% := A_LoopReadLine
}

; read from the Array:
Loop %ArrayCount%
{
    element := Array%A_Index%
    MsgBox % element
}
FileDelete, C:\screenshots.txt
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2010, 4:57 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Why two loops? You may create the pseudo-Array as well as the text file from the first loop itself.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Google Feedfetcher, mrhobbeys, rbrtryn and 62 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group