AutoHotkey Community

It is currently May 26th, 2012, 4:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: file name into variable?
PostPosted: March 21st, 2008, 12:39 am 
I'm trying to list the files in a directory and store the name of a type of file into a variable. For example:

default.txt
default.NRT
default.N2

I'm trying to get the name of the NRT file so I can overwrite it with another file. I'm able to loop through the directory but not able to put the name of the NRT file into a variable.

Can someone point me in the right direction or provide a snippet?

thanks


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2008, 1:01 am 
Offline

Joined: February 9th, 2006, 8:36 pm
Posts: 338
Code:
loop,*.nrt
{
  nrtfile:=A_LoopFileName
.....................
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2008, 2:22 am 
hmmm that doesn't seem to work for some reason. Not sure yet why.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 21st, 2008, 11:39 pm 
ok I think whats happening is that the global variable never gets populated inside the loop.

global nrtfile:=A_LoopFileName

throws and error


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 22nd, 2008, 12:19 am 
Offline

Joined: February 9th, 2006, 8:36 pm
Posts: 338
maybe spearate the declaration and assignment?
Code:
global nrtfile
................
loop,*.nrt
{
  nrtfile:=A_LoopFileName
.....................
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 22nd, 2008, 12:44 am 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
Code:
FindFiles(Type, Path) {
   Loop, %Path%\*.%Type%
   {
      files .= A_LoopFileName "|"
   }
   Return files
}


Example:

Code:
Gui, +ToolWindow
Gui, Add, DropDownList, w100 h100, % FindFiles("ahk", A_ScriptDir) ; Populate the DDL with all of the files of the file type specified.
Gui, Show,, DDL Test


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 22nd, 2008, 12:46 am 
Is the NRT file in the sript's working dir?
If not you need to specify the file path or set the working directory to the right place
Code:
SetWorkingDir %A_ScriptDir% ; or where ever the file is located


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 13 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