N
N
NeO_n2021-05-26 01:59:27
cmd/bat
NeO_n, 2021-05-26 01:59:27

How to write a bat file to move folder D:\1 to D:\x\1, where X is current date in day, month, hour, minute format?

The whole question is in the header. There is a task that I previously performed through the clicker, but the software has the ability to pull up .bat, but I am not familiar with writing. I hope to write this really)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2021-05-26
@hint000

set X=%DATE:~3,2%-%DATE:~0,2%-%time:~0,2%-%time:~3,2%
if "%time:~0,1%" == " " set X=%DATE:~3,2%-%DATE:~0,2%-0%time:~1,1%-%time:~3,2%
mkdir "D:\%X%"
move "D:\1" "D:\%X%\"
X is the current date in the format MM-DD-HH-mm (month-day-hour-minute)
. Accountants do this, but not IT people. I once tried to explain to accountants why IT people use such a "strange" format ГГГГ-ММ-ДД, but without much success. In the eyes read:
Children, the word boy and the word sol are written with a soft sign, and the words fork and plate without a soft sign, it’s impossible to understand, you just need to remember.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question