[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 170
  • Last Modified:

parameter as a Filename

I am trying to pass a paramater as a file name something to the effect of

Set name = %1
echo 2> C:\ %name%_Finished.txt

The expected resukts should be
Bill_Finished.txt

Does anyone know how I would go about acomplishing?
0
earngreen
Asked:
earngreen
  • 2
1 Solution
 
Shift-3Commented:
Just remove the extra spaces and the 2 from the second line (2> is used to redirect errors to a file rather than standard output).  Change echo to echo. to echo a single blank line.  It's also usually a good idea to enclose the file path in quotes in case it contains a space.




Set name=%1
echo. > "C:\%name%_Finished.txt"

Open in new window

0
 
Shift-3Commented:
Also if your parameter might have quotes around it then you should use %~1 to remove them.

Here are some useful references:
http://www.ss64.com/ntsyntax/redirection.html
http://www.ss64.com/ntsyntax/parameters.html
http://www.ss64.com/nt/set.html


set name=%~1
echo. > "C:\%name%_Finished.txt"

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now