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

Does anyone know how I would go about acomplishing?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Also if your parameter might have quotes around it then you should use %~1 to remove them.

Here are some useful references:

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

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.