【发布时间】:2021-03-21 08:51:42
【问题描述】:
我正在编写一个批处理文件,以将文件夹的内容复制到同一目录中具有新名称的文件夹中。我希望命名约定是: 2021000-Template(这是复制文件的地方) 2021001-A公司 2021002-公司B 等等
我正在提示输入公司名称,但卡在最后一部分。
如何找到目录中最后一个文件夹的名称,将202100x存入一个变量并加1?
之后我需要将新变量包含在带有 cname 的字符串中,但我想我可以解决这个问题。
感谢您的帮助!
@echo off
:: CD to correct folder and year in the root
CD\Estimates\2021
:: Asks for user input on company name and stores it in the cname var
Set /P "cname= Enter Company Name (without spaces): "
:: Copying the entire contents of the Template folder to a new folder named the cname
XCOPY C:\Estimates\2021\2021000-Template C:\Estimates\2021\%cname% /S /I
:: Opens the new folder
start C:\Estimates\2021\%cname%
【问题讨论】:
标签: batch-file directory find