简体   繁体   English

for循环在Windows批处理中不起作用

[英]for loop is not working inside of a windows batch

I want to execute this in a Windows batch: 我想在Windows批处理中执行此操作:

for /F %%A In ('PowerShell Get-Date -UFormat %V') do copy "D:\Versand\Test\OrdersOffers.xlsm" "D:\Versand\Test\OrdersOffersWeek%%A.xlsm"

But nothing is happening. 但是什么也没发生。 It works if I do it in CMD like this: 如果我在CMD中这样做,它将起作用:

for /F %A In ('PowerShell Get-Date -UFormat %V') do copy "D:\Versand\Test\NL_OrdersOffers.xlsm" "D:\Versand\Test\NL_OrdersOffers%A.xlsm"

What could be the problem? 可能是什么问题呢?

 -UFormat %V

becomes

 -UFormat %%V

because % is a special character that needs to be escaped by % itself 因为%是一个特殊字符,必须由%自身转义

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM