I have a file named !Template - Year End Report.doc
.
I'm trying to use the following command:
copy !Template* customer_name*
The result is customer_nameear End Report.doc
.
If I use a shorter name, like this:
copy !Template* cust1*
Then I get this output: cust1late - Year End Report.doc
How can I make it replace "!Template" with the customer name, regardless of length?
no chance to do it with just copy
. Use a for
to split the filenames:
for /f "tokens=1* delims=-" %a in ('dir /b !Template*') do @echo copy "%a-%b" "cust -%b"
(to use in a batchfile, use %%a
and %%b
instead of %a
and %b
)