WiseScript Package Editor : How to get a filename ?
04/24/2015 1680 views
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..
Answer Chosen by the Author
Please log in to 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.
Answered 04/25/2015 by: EdT