简体   繁体   中英

for loop is not working inside of a windows batch

I want to execute this in a Windows batch:

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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