How can i get newest subfolder in directory ?
I need it in MKLINK /D command.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
(
%ifor windows 10)/bis for bare format/ad-honly directories, but not the hidden onest:cmeans to use the creation date for sorting (uset:wfor last write date)/odsort oldest firstfor /Fexecutes the command and sets a to the directory name, the last one is the newest one.If you execute this directly on the command line (not in a batch file), use
%instead of%%.This works with the current directory – as @iesou pointed out you’ll need to add the directory path after
dirif you need to use any other directory path.Example with specified directory path:
To prevent going through all subfolders, you may change the sort order to have the most recent first (
/o-d) and exit the for loop after the first call: