parameter as a Filename

Posted on 2008-11-18
Last Modified: 2012-05-05
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?
Question by:earngreen
    LVL 38

    Expert Comment

    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

    LVL 38

    Accepted Solution

    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


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
    How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now