Windows Command line basics

Posted on 2008-11-06
Last Modified: 2012-05-05
I need a .cmd file to create a directory based on value supplied as arg 2 and copy all of the files from a directory whose name is partially suppllied by arg1

I want to be able to enter "test  1234 5678" and have a directory named 5678ver made and all of the files copied from 1234ver into it.

I cut/pasted what I have done thus far and for some reason it does not do the copy....the directory gets created OK but the files do not get copied....

echo on
if "%1"=="" goto badArgs
if "%2"=="" goto badArgs
mkdir %2%ver
copy "%1%ver\*.for %2%ver\*.*"  
goto exit

Echo "Old and new numbers required as start arguments"
Question by:smm57
    LVL 30

    Accepted Solution

    Hi smm57,

    IMO there are two problems:

    1. Instead of using '%1%' and '%2%' in the 'copy'-statement you should use '%1' and '%2'
    2. With escaping the whole expression after 'copy' by "-s the whole expression is passed as one argument.

    This should work - replace this line:

    > copy "%1%ver\*.for %2%ver\*.*"  

    with this one:

    > copy "%1ver\*.for" "%2ver\*.*"

    Hope that helps,


    Author Closing Comment

    Yes, that did it thanks

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Our Group Policy work started with Small Business Server in 2000. Microsoft gave us an excellent OU and GPO model in subsequent SBS editions that utilized WMI filters, OU linking, and VBS scripts. These are some of experiences plus our spending a lo…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

    745 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

    16 Experts available now in Live!

    Get 1:1 Help Now