/build/static/layout/Breadcrumb_cap_w.png

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
  • not clear on questions ..

    Wise script " Search for file" can get u file name in variable if that is what you want .. - rock_star 9 years ago
  • Hello Rock_star, thank you for the feedback, I've looked at this command, but we must give the full file name (from the help :

    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
  • I would use vb-script or any other script that can get the name of all the files from that folder ( in your case all pdf files ) to c:\abc.txt and read this file from wise script.. - rock_star 9 years ago
  • Thank you both for the help ;o) I'm just seeing your post, and glad to see I've found the right way so last friday, I've used a batch command "forfiles /m *.pdf /c "cmd /c echo @file >> srname.txt"" then I'm able to read and work on the srname.txt file. Shame that Wise didn't contain such option like that..
    Thank you again. - keihilin 8 years ago

Answers (1)

Answer Summary:
Posted by: EdT 9 years ago
Red Belt
2

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.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ