N
N
Nikita2019-11-03 00:44:24
cmd/bat
Nikita, 2019-11-03 00:44:24

How to sort by day, month or year of file creation?

There is such a task: Display the contents of the folder, sorted by choice (using the choice command) by days, months or years of creation of files. The name of the folder is taken as a parameter of the batch file.
I see the solution something like this, but I don’t know how to sort by days, months or years of file creation.
Tell me how to sort by days, months or years of file creation?

ECHO OFF
cls
 
set "pass=Specify the path to the file:"
set /p "pass=%pass%"
echo. %pass%
 
echo. Choose 1, 2 or 3
echo. 1 - sort by day
echo. 2 - sort by month
echo. 3 - sort by years
 
choice /c 123 /n
set oper=%errorlevel%
 
if %oper% == 1 (echo. Sorted by day && dir "%pass%" )
if %oper% == 2 (echo. Sorted by months && dir "%pass%")
if %oper% == 3 (echo. Sorted by years && dir "%pass%")
pause

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question