| 1. |
Solve : Inserting today's date in a filename via a batch file? |
|
Answer» I've created a simple batch file that copies a DOZEN small files from multiple directories into a single directory and then compresses them into a zip file. I have to do this each day, then ftp the zip file to a co-worker in another facility. Wed 03/05/2008 OK so it's US date format Quote Is there a way, within a batch file, to extract the current date, convert it to yyyymmdd format, and then rename zipfile.zip to zipfileyyyymmdd.zip? set today=%date:~10,4%%date:~7,2%%date:~4,2% ren zipfile.zip zipfile%today%.zip I plugged this into my existing batch file, and it worked like a charm. Thank you so much for the assist!! Quote from: Dias de verano on March 05, 2008, 11:55:26 AM set today=%date:~10,4%%date:~7,2%%date:~4,2% Just noticed this morning that the above syntax re-formats the date as YYYYDDMM as opposed to yyyymmdd. Simple fix, though. Thanks again! You're right; I guess I missed it because I'm used to the European dd-mm-yyyy format. But you overcame that. |
|