更改 Windows 中 'dir' 命令的默认排序顺序

更改 Windows 中 'dir' 命令的默认排序顺序

默认情况下,Windowsdir命令按字母顺序对文件和目录进行排序,而不进行分组。结果是文件和目录相互交错。示例输出:

F:\Dev Kits>dir
 Volume in drive F is Buffer II
 Volume Serial Number is E039-C389

 Directory of F:\Dev Kits

07/26/2011  05:02 AM    <DIR>          .
07/26/2011  05:02 AM    <DIR>          ..
10/08/2009  05:41 PM           408,330 Bat To Exe Converter 1.5.zip
07/26/2011  04:53 AM    <DIR>          Boost
10/27/2009  09:37 PM        20,248,963 CodeBlocks 8.02 Mingw.exe
02/20/2010  12:26 AM         1,251,993 CodeBlocks Manual.pdf
04/18/2010  05:39 PM           610,769 Dependency Walker 2.2.6000 x86.zip
05/29/2010  04:37 PM             4,387 Dev Kits.sha2
07/26/2011  04:59 AM    <JUNCTION>     iOS SDK
01/31/2011  09:40 PM        35,213,765 MinGW GCC 4.4.0_1.zip
11/17/2009  01:41 AM         2,834,808 Notepad++ Portable 5.5.1.exe
01/07/2010  06:04 PM         3,860,528 Notepad++ Portable 5.6.4.exe
11/17/2009  12:31 AM           261,563 Notepad2 4.0.23.zip
03/08/2011  07:07 PM         9,932,872 Opera Mobile 10.1 Emulator.exe
05/25/2010  08:46 AM           162,506 PC-Police.zip
04/05/2010  10:37 PM    <DIR>          Python
07/26/2011  05:02 AM    <DIR>          Qt Framework and SDK
04/05/2010  10:35 PM    <DIR>          Series 80 SDK
07/26/2011  04:52 AM    <DIR>          Symbian SDK
07/26/2011  05:00 AM    <DIR>          Unit Testing
07/26/2011  04:51 AM    <JUNCTION>     Visual Studio Tools
04/07/2011  04:51 PM        17,349,072 Win32 OpenSSL 1.0.0d.exe
02/19/2010  11:05 PM           397,056 Win32pp Compiled Samples.zip
07/26/2011  04:53 AM    <DIR>          Windows Phone SDK
07/26/2011  04:52 AM    <DIR>          Windows Platform SDK
11/14/2009  07:49 PM        12,811,696 wxMSW 2.8.10 Setup.exe
11/15/2009  01:34 AM             2,808 wxMSW Installation.txt
              15 File(s)    105,351,116 bytes
              12 Dir(s)   1,346,224,128 bytes free

添加/OGN开关使输出更加有条理:

F:\Dev Kits>dir /ogn
 Volume in drive F is Buffer II
 Volume Serial Number is E039-C389

 Directory of F:\Dev Kits

07/26/2011  05:02 AM    <DIR>          .
07/26/2011  05:02 AM    <DIR>          ..
07/26/2011  04:53 AM    <DIR>          Boost
07/26/2011  04:59 AM    <JUNCTION>     iOS SDK
04/05/2010  10:37 PM    <DIR>          Python
07/26/2011  05:02 AM    <DIR>          Qt Framework and SDK
04/05/2010  10:35 PM    <DIR>          Series 80 SDK
07/26/2011  04:52 AM    <DIR>          Symbian SDK
07/26/2011  05:00 AM    <DIR>          Unit Testing
07/26/2011  04:51 AM    <JUNCTION>     Visual Studio Tools
07/26/2011  04:53 AM    <DIR>          Windows Phone SDK
07/26/2011  04:52 AM    <DIR>          Windows Platform SDK
10/08/2009  05:41 PM           408,330 Bat To Exe Converter 1.5.zip
10/27/2009  09:37 PM        20,248,963 CodeBlocks 8.02 Mingw.exe
02/20/2010  12:26 AM         1,251,993 CodeBlocks Manual.pdf
04/18/2010  05:39 PM           610,769 Dependency Walker 2.2.6000 x86.zip
05/29/2010  04:37 PM             4,387 Dev Kits.sha2
01/31/2011  09:40 PM        35,213,765 MinGW GCC 4.4.0_1.zip
11/17/2009  01:41 AM         2,834,808 Notepad++ Portable 5.5.1.exe
01/07/2010  06:04 PM         3,860,528 Notepad++ Portable 5.6.4.exe
11/17/2009  12:31 AM           261,563 Notepad2 4.0.23.zip
03/08/2011  07:07 PM         9,932,872 Opera Mobile 10.1 Emulator.exe
05/25/2010  08:46 AM           162,506 PC-Police.zip
04/07/2011  04:51 PM        17,349,072 Win32 OpenSSL 1.0.0d.exe
02/19/2010  11:05 PM           397,056 Win32pp Compiled Samples.zip
11/14/2009  07:49 PM        12,811,696 wxMSW 2.8.10 Setup.exe
11/15/2009  01:34 AM             2,808 wxMSW Installation.txt
              15 File(s)    105,351,116 bytes
              12 Dir(s)   1,346,224,128 bytes free

问题:是否可以默认dir使用该开关?/ogn

答案1

环境%DIRCMD%变量可用于指定默认值dir

答案2

尝试打开控制面板>系统>高级选项卡>环境变量。

创建系统变量DIRCMD并赋值/a /c /p /x /o:gen

相关内容