Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

Windows Command line basics

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

:badArgs
Echo "Old and new numbers required as start arguments"
:exit
0
smm57
Asked:
smm57
1 Solution
 
ZoppoCommented:
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,

ZOPPO
0
 
smm57Author Commented:
Yes, that did it thanks
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

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