Batch copy file with current date in file name

How to copy files from one directory to another, whose names contain current date, and so the names change daily.

Example:

File name: Test_14042021.txt
Date today: 14/04/2021 // DDMMYYYY

I tried this, but it didn't work:

copy Test_%date:~12,10%%date:~4,2%%date:~7,2%.txt D:\

1 Answer

Try copy Test_%date:~8,2%%date:~5,2%%date:~0,4%.txt D:\

You can use echo Test_%date:~8,2%%date:~5,2%%date:~0,4%.txt to see what exactly you pass to copy. Fine-tune it until you see your actual file name.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like