WiseScript Package Editor : How to get a filename ?
Hello,
I'm a little bit rusty in WiseScript use.. And I would like to detect each file with .pdf as extension from the current folder, then put detected filename in a variable.
I can detect if there is some PDF file available (using : Check if file) but I do not find the right command to put the filename into a variable.
Is it at least possible ? that's seems obvious to me to be able to do that.. but..
Thanks.
4 Comments
[ + ] Show comments
Answers (1)
Answer Summary:
Please log in to answer
Posted by:
EdT
9 years ago
Top Answer
The problem you face is that you don't know the names of the PDF files you are looking for and Wisescript does not natively offer any directory listing commands. The approach I would use would involve creating a temporary file by using the Execute Program command to run:
c:\windows\system32\cmd.exe /c dir /s <path>\*.pdf > %temp%\listing.txt
You can of course add other parameters to the DIR command according to need. If only one folder is involved use the /B switch as this just gives you a list of filenames without other text.
One you have done that, you then parse the text file one line at a time into your variable, and do what you then need to do with each PDF. Include code to skip the line if it does not include .pdf in it (remember to do your comparisons ignoring case).
At the end, remember to delete the text file in temp.
This follows much the same overall logic as rock_star mentions above, but without having to use VBScript if you don't want to. On the other hand, recent versions of Wisescript as included in the Package Studio or Installation Studio products would allow calls to VBScript from within Wisescript.
I love the power of Wisescript, but unfortunately it has not been upgraded properly into the Installshield product and has more bugs than an anthill.
Wise script " Search for file" can get u file name in variable if that is what you want .. - rock_star 9 years ago
Enter the name of the file to search for. The file name can contain wildcard characters (*, ?).)
In my case, I do not know the file name, I just know the extension ".pdf" and I would like to capture the filename into a varable in order to parse it and get a specific info from the file name. - keihilin 9 years ago
Thank you again. - keihilin 9 years ago