Solved

How Do You Pass a Filename as a Variable from a Batch File to a VBScript?

Posted on 2008-06-25
2
590 Views
Last Modified: 2012-08-14
I am trying to script out a process where a ZIP file gets renamed and then FTP'd.  I wrote a batch file that renames a ZIP file to include the current date and time.  I have another VBScript file to upload a specified file.  The filename is passed along fine as I tested it by running an echo and it showed the right name.  I'm stuck in the VBScript file where I'm trying to use the value of the variable with the filename as part of the file path.  The path tells the FTP application what file to upload.

The batch file has the following code to call the VBScript file:
WScript upload.vbs %name%

The VBScript has the following code to pick that up and display it to make sure it's correct:
Dim file_name
file_name = WScript.Arguments(0)
WScript.Echo file_name

I have a problem later in the script because it looks for a file named "&file_name", not the value of the variable "file_name".  My syntax is probably incorrect.:
MySite.Upload "C:\FILES\&file_name", "/WEBSITE/&file_name"

0
Comment
Question by:doser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
JesterToo earned 250 total points
ID: 21871234
Change that line to this...

   MySite.Upload "C:\FILES\" & file_name, "/WEBSITE/" & file_name

Also, be aware that if your code ever needs to handle a "file_name" with an embedded space that more changes would be necessary.
0
 
LVL 1

Author Closing Comment

by:doser
ID: 31470828
I knew it was something with my syntax, but I just couldn't figure it out.  I spent a whole day at the job working on just that part.  Thanks so much.
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question