I need to write a batch file that copies a file to existing folder and renames it with current month and year.
At the moment, my batch file consists of only this command:
@ECHO OFF copy /y D:\\SalesMixExp\\Sales_Mix_v1.2_082015.xlsx D:\\SalesMixExp\\Sales_Mix_v1.2_092015.xlsx**
I am running this every month and it works fine. But every time I am changing the newly created filename with current month and year. ie for ex: 092015 in my filename is sep2015 and for next month it should be automatically renamed as Sales_Mix_v1.2_102015
Please help me in resolving my problem. So that I don't have to change it every month.
At last I found the answer......
@echo off set Date=%date:~4,2%%date:~10,4% copy D:\\SalesMixExp\\Sales_Mix_v1.2_082015.xlsx D:\\SalesMixExp\\Sales_Mix_v1.2_%Date%.xlsx
But it works fine only when the file or folder names doesn't contain gaps.
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.