- NSIS Discussion
- Search for File + Wildcard
Archive: Search for File + Wildcard
coopey247
11th August 2004 13:58 UTC
Search for File + Wildcard
How do you find a file by use of a wildcard. I need to edit java settings in C:\Docs+Set\user\.java\properties131_**, where the ** can be anything from 01 - 25.
I know to use ReadEnvStr to get the users folder, but I need to open that properties file, no matter what the trailing numbers are.
Thanks in advance.
NSIS rules.
Coop
deguix
11th August 2004 14:05 UTC
Has some functions in Archive that do exactly that.
coopey247
11th August 2004 14:10 UTC
I searched and searched and couldn't find any. There were plenty of functions that found the directory if you had the file name, but not the file name if you know the directory.
deguix
11th August 2004 14:27 UTC
There were plenty of functions that found the directory if you had the file name, but not the file name if you know the directory.
You can use the "Search for a File" or "Search for File or Directory (Alternative)" functions to search for directories too. Like I have in my program (using "Search for File or Directory (Alternative)"):
Function YourFunction
Push "properties131_??"
Push "C:\Docs+Set\user\.java"
Push $0
GetFunctionAddress $0 "Search"
Exch $0
Push 0
Push 0
Call SearchFile
FunctionEnd
Function Search
# Your code for each folder, or for only one folder.
Push "go" ;or Push "stop" if you don't want to search anymore.
FunctionEnd
coopey247
11th August 2004 15:16 UTC
Maybe I am just not reading them right, but I looked at both of the functions you referenced and both wanted a "certain file". I don't know the file name, I know part of the file name, I want to find the rest of it.
Secondly, I dont understand the function you posted. Say I wanted to simply delete the file, where would that one line of code go?
Thanks deguix, I appreciate the help.
deguix
11th August 2004 15:41 UTC
Oh, you wanted to delete the file...... But that's even easier! Just use:
Delete "C:\Docs+Set\user\.java\properties131_*.*"
I thought you wanted to search a file or folder because of the quote:
How do you find a file by use of a wildcard.
coopey247
11th August 2004 18:56 UTC
Sorry, I was just trying to use that as an example so I could see where to insert my code. I want to open the file, and replace a string (I've already got code to do that). I just wanted to see where in your example to do that.
Afrow UK
11th August 2004 19:12 UTC
Just use FindFirst, FindNext etc
E.g.
FindFirst $R0 $R1 "X:\path\to\files*.*"
Loop:
Push $R0 ;store file handle
Push "X:\path\to\$R1" ;current found file
Push ...
Call Func
Pop $R0
ClearErrors
FindNext $R0 $R1
IfErrors 0 Loop
FileClose $R0
-Stu