order for loop output command prompt

1

1

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)?

John Hunt

Posted 2011-03-27T08:17:28.923

Reputation: 2 739

Answers

1

Just add sort

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

Nifle

Posted 2011-03-27T08:17:28.923

Reputation: 31 337