สวัสดีครับ  วันนี้ว่าด้วยเรื่อง การดู ไฟล์และ ไดเร็คทอรี่ (โฟร์เดอร์) บทนี้ยาวหน่อยนะครับ นั้นก็คือ คำสั่ง DIR 
โดยปกติหากเราเล่นด้วย GUI (Graphical User Interface) หรือ รูปแบบWindows ก็ได้ เวลาเรา้เข้าไปในโฟล์เดอร์
โดยปกติหากเราเล่นด้วย GUI (Graphical User Interface) หรือ รูปแบบWindows ก็ได้ เวลาเรา้เข้าไปในโฟล์เดอร์
แต่ใน Command Line นั้น หากต้องการให้แสดงต้อง ใช้คำสั่งเพื่อให้
คำสั่งนี้สามารถแสดงไฟล์หรื
 ยกตัวอย่างง่ายๆเช่น
DIR
Display a list of files and subfolders
Syntax
      DIR [pathname(s)] [display_format] [file_attributes] [sorted] [time] [options]
Key
   [pathname] The drive, folder, and/or files to display, 
              this can include wildcards:
                 *   Match any characters
                 ?   Match any ONE character
   [display_format]
   /P   Pause after each screen of data.
   /W   Wide List format, sorted horizontally.
   /D   Wide List format, sorted by vertical column.
   [file_attributes] /A[:]attribute 
   /A:D  Folder         /A:-D  NOT Folder
   /A:R  Read-only      /A:-R  NOT Read-only 
   /A:H  Hidden         /A:-H  NOT Hidden
   /A:A  Archive        /A:-A  NOT Archive
   /A:S  System file    /A:-S  NOT System file
   /A:I  Not content indexed Files  /A:-I  NOT content indexed
   /A:L  Reparse Point  /A:-L  NOT Reparse Point (symbolic link)
   /A:X  No scrub file  /A:-X  Scrub file    (Windows 8+)
   /A:V  Integrity      /A:-V  NOT Integrity (Windows 8+)
   /A    Show all files
   Several attributes can be combined e.g. /A:HD-R
   [sorted]   Sorted by /O[:]sortorder
   /O:N   Name                  /O:-N   Name
   /O:S   file Size             /O:-S   file Size
   /O:E   file Extension        /O:-E   file Extension
   /O:D   Date & time           /O:-D   Date & time
   /O:G   Group folders first   /O:-G   Group folders last
   several attributes can be combined e.g. /O:GEN
   [time] /T:  the time field to display & use for sorting
   /T:C   Creation
   /T:A   Last Access
   /T:W   Last Written (default)
   [options]
   /S     include all subfolders.
   /R     Display alternate data streams. (Vista and above)
   /B     Bare format (no heading, file sizes or summary).
   /L     use Lowercase.
   /Q     Display the owner of the file.
   /N     long list format where filenames are on the far right.
   /X     As for /N but with the short filenames included.
   /C     Include thousand separator in file sizes. 
   /-C    Don’t include thousand separator in file sizes.
   /4     Display four-digit years
------------------------------
ก่อนอื่นมารู้ถึงอักขระพิ
* Match any characters คือ ทุกตัวอักษร
เช่น เราต้องการหาไฟล์เฉพาะนามสกุล txt เท่านั้น ให้ใช้คำสั่ง
>> dir *.txt
เราต้องการหาไฟล์ ขึ้นต้นด้วย B ตามด้วยทุกตัวอักษรและลงท้ายด้วย1ให้ใช้คำสั่ง 
>> dir B*1
------------------------------------------------------------ ------------------------------ ------------- 
คำสั่งที่อาจจะต้องใช้ประจำ 
option  /P คือคำสั่งหยุดหน้าจอกรณีที่มี
>> dir /P
 
ให้กดปุ่มใดๆก็ได้เพื่อให้แสดงต่อหากแสดงเกินหน้าก็ยังจะมีขึ้นความ Press any key  to continue ต่อ 
 
 ------------------------------------------------------------ ------------------------------ ------------- 
dir /w เปลี่ยนรูปแบบแสดง dir เป็นแนวกว้าง
------------------------------------------------------------ ------------------------------ ------------- 
dir /b แสดงเฉพาะชื่อเท่านั้น  ตัดวันเวลา ขนาดไฟล์ และอื่นๆ
------------------------------------------------------------ ------------------------------ ------------- 
dir /s ใช้แสดงไดเร็คทรอรี่ย่อยทั้
ถ้าไปอยู่ใต้ไดร์ C:\ มันจะแสดงทุกๆโฟร์เดอร์ที่มี
ตัวนี้เวลาจะใช้เหมือนการหาไฟล์
ผมต้องการหา โฟร์เดอร์ Backup 
C:\Users\hongfong_k>dir backup /s /p /b  ความหมายคือ แสดงโฟร์เดอร Backup และค้นหาโฟล์เดอร์ย่อยด้วย ให้หยุดหาเต็มหน้าจอ และแสดงเฉพาะชื่อเท่านั้น 
ผลคือทุกโฟร์เดอร์ที่ชื่อตรง Backup จะแสดงพร้อม path
 
ไม่มีความคิดเห็น:
แสดงความคิดเห็น