I'm using the following command to list some of my favorite videos in a directory (and redirect the output into a text file):

for %i in (*avi *.mkv *mp4) do @echo %~ni

I'd like to alphabetically order the output of this command. I think I'd probably use sed or awk or something under Linux, but I'm on Windows 7 here using the command prompt (and soon, a batch file).

How would I achieve this (without using some external program or language)?


Just add sort

(for %i in (*avi *.mkv *mp4) do @echo %~ni) | sort

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.