As an example, I have a structure like this:
C:\Projects\16-100
C:\Projects\16-101
C:\Projects\16-102
...
Except that there is also descriptive information after the number:
C:\Projects\16-100-FirstProject-OtherDescriptiveStuff
C:\Projects\16-101-SecondProject-Canceled
C:\Projects\16-102-OtherStuff
...
I want to open a folder with Autohotkey (and then save documents there etc.) using only the number of the folder. Is there some kind of way to use "wildcards" or some other method to still open the folder?
Is there a way to open folder with partial information?
Re: Is there a way to open folder with partial information?
What do you mean by opening?
I haven't done any testing, but I'd do this:
This will run the first match that begins with 16-100 and open it up in explorer.
I haven't done any testing, but I'd do this:
Code: Select all
Loop, Files, C:\Programs\16-100*, D
{
Run, A_LoopFileFullPath
Break
}
Re: Is there a way to open folder with partial information?
Thanks.
I think I was unclear with "open". What I want to do is create folders and files in that particular folder.
I think I was unclear with "open". What I want to do is create folders and files in that particular folder.
-
- Posts: 1259
- Joined: 16 Apr 2015, 09:41
Re: Is there a way to open folder with partial information?
You cannot create a file or folder using a wildcard. Wildcards can only be used with items that already exist.
Re: Is there a way to open folder with partial information?
If you're creating folders and files with AHK, you've at least got a way to capture the preceeding part of the file path. Just use this:
(I'm not aware of a native AHK command for creating a new folder, but, there may well be. Edit: Here it is: FileCreateDir)
Code: Select all
Loop, Files, C:\Programs\16-100*, D
{
path:=A_LoopFileFullPath
Break
}
FileAppend, Hello World, %path%\MyNewFile.txt
return
Re: Is there a way to open folder with partial information?
Creates a directory/folder.
fileCreateDir, DirName
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
*poke*
Is it December 21, 2012 yet?
Re: Is there a way to open folder with partial information?
Laie wrote:As an example, I have a structure like this:
C:\Projects\16-100
C:\Projects\16-101
C:\Projects\16-102
...
Except that there is also descriptive information after the number:
C:\Projects\16-100-FirstProject-OtherDescriptiveStuff
C:\Projects\16-101-SecondProject-Canceled
C:\Projects\16-102-OtherStuff
...
I want to open a folder with Autohotkey (and then save documents there etc.) using only the number of the folder. Is there some kind of way to use "wildcards" or some other method to still open the folder?
Hi try this:
Code: Select all
Loop, Files, 16-100*, D
{
path:=A_LoopFileFullPath
Break
}
IfExist, %path%
{
Run, %path%
FileAppend, Existing Folder`n, %path%\MyNewFile.txt
}
else
{
Run %comspec% /c "MKDIR 16-100" ;Command window, More at : http://ss64.com/nt/
Run, 16-100\
FileAppend, New Folder`n, 16-100\MyNewFile.txt
}
return
![Waving :wave:](./images/smilies/icon_wave.gif)
![Wink ;)](./images/smilies/icon_e_wink.gif)
Re: Is there a way to open folder with partial information?
YoucefHam: Thanks, that just about did it.
The only problem I am running into is that I have a variable further up in the program for the project number.
Let's say that vprojectnumber gets set equal to 16-102
The command "Loop, Files ..." apparently doesn't allow variables in its file pattern.
So this does not work (I also tried combinations of quotation marks and percentage signs):
Loop, Files, C:\Projects\%projectnumber%*, D
Is there some way to build up the path with a variable and then insert it into the file pattern for "Loop, Files ..."? Or some other way around this?
The only problem I am running into is that I have a variable further up in the program for the project number.
Let's say that vprojectnumber gets set equal to 16-102
The command "Loop, Files ..." apparently doesn't allow variables in its file pattern.
So this does not work (I also tried combinations of quotation marks and percentage signs):
Loop, Files, C:\Projects\%projectnumber%*, D
Is there some way to build up the path with a variable and then insert it into the file pattern for "Loop, Files ..."? Or some other way around this?
Re: Is there a way to open folder with partial information?
Variables do work in the file path. What you have should work; Loop, Files, C:\Projects\%projectnumber%*, D. Double check that projectnumber has the value you want with MsgBox %projectnumber% before the loop file is run. I noticed you said that it was vprojectnumber is 16-102 . Two possible problems I can think of. One, your variable actually does have the v in it. I assume this is a GUI though. If it is a GUI, and in the gui control you used "vprojectnumber", then the actual name of the variable is "projectnumber". However, if this isn't a GUI, double check if the v should be there or not, and also double check you're not using the := operator. That operator would treat 16-102 as an expression, which treats it as 16 minus 102, which is -86.
Re: Is there a way to open folder with partial information?
Exaskryz,
Thanks - I got it working. I just had a typo.
Thanks - I got it working. I just had a typo.
Who is online
Users browsing this forum: Bing [Bot], Draken, Google [Bot], oktavimark, Spawnova, william_ahk and 283 guests