Command Prompt - Intermediate Commands

h) cd/chdir
      CD refers to the Current Directory, but CD or chdir commands are used for changing subdirectories(In Windows, Subdirectory refers to a folder). using the cd command you can enter into a subdirectory or exit from a subdirectory.
           Syntax: cd directory name (The commands only works on the current directory.)
                        cd "directorylocation(With directory)"
                        cd.. (This command helps you to come back to the parent directory)
                        cd\ (It helps you to come into Root Directory)


i) del/erase
      This command is used for deleting files. It is similar to deleting a file by pressing 'Shift+delete'. The file will be deleted permanently(Also you can recover files using recovery software).
           Syntax: del "filelocation\filename"
                        del /q "filelocation\filename" (The command helps you to skip delete confirmation message.)
                              /s (It will remove all files into this directory and subdirectories. So use it with caution)
                              /f ('/f' means it will forcefully delete read-only files)
                              /a:r ('/a' means file attributes ':r' means read-only, means if the current file is read-only then it will delete the file)
                              /a:h (only deletes the file if the file is hidden)
                              /a:s (only deletes the system file)
If you want to delete a file which attributes is hidden and system, use 'del /a:hs' do not use 'del /a:h /a:s'

If you choose any directory instead of a file then all files will be deleted into this directory.

j) ren/rename
       ren/rename commands help you file name without touching file contains. Also, You can change the file extension using this command. You can't change the folder name using this command.
           Syntax: ren "filelocation\oldfilename.extension" "newfilename.extension"

Tip: All files have their own extension, so you need to provide a file extension after the file name.

k) md/mkdir
       md commands help you to create a new directory using the command prompt.
           Syntax: md "location/directoryname"

l) rd/rmdir
       opposite to md command. This command helps you to delete directories/subdirectories. Only the command works on those directories/subdirectories if it is empty.
           Syntax: rd "location/directoryname" (Only works if the directory is empty)
                        rd /s "location/directoryname" (It breaks the rule of rd command, means it deletes directory forcefully without checking what is inside of it, but it give alert when you use this command. So use it with caution.)
                            /q (It deletes directory without giving )

m) copy
       copy command used for copying one or multiple files at once to one to another directory. Using this command you can't copy any directory, only the directory files will be copied.
          Syntax: copy "filelocation\filename" (It helps you to copy file from file location to current location)
                      copy "filelocation1\filename" "filelocation2" (It will copy file from file location 1 to file location 2)
                      copy /y "filelocation1\filename" "filelocation2" (/y means if any file exist into filelocation2 which filename and extension is similar to filelocation1 filename, then the file will be overwritten)

n) move
       It is used for moving any file/directory to another location.
         Syntax: move has the commands like copy command
                      move "filelocation\filename(It helps you to move file from file location to current location)
                      move "filelocation1\filename" "filelocation2" (It will move file from file location 1 to file location 2)
                      move /y "filelocation1\filename" "filelocation2" (/y means if any file exist into filelocation2 which filename and extension is similar to filelocation1 filename, then the file will be overwritten)

o) color
       It will change the color of the console window.
         Syntax: color [console][text]
                      1 = Blue 2 = Green 3 = Aqua 4 = Red 5 = Purple 6 = Yellow 7 = White
                      8 = Gray 9 = Light Blue A = Light Green B = Light Aqua C = Light Red
                      D = Light Purple E = Light Yellow F = Bright White
Tip: If you use the same attributes means, if you used 'color00' or 'color aa' then your request will not be granted.

p) dir
       It helps you to view current directory files and subdirectories into the console window.
           Syntax: dir "location/directoryname" (If you used cd command then you no need to provide directory location)
                     dir /b "location/directoryname" (It only gives filenames, not file details)
                          /q (It helps to display the ent owner of the files/subdirectories)
                          /s (It only shows you files into subdirectories)
                          /t:c (It helps you to show the creation date of files/subdirectory)
                          /t:a (It used for checking file access time/date)
                          /t:w (It checks when the file is last modified)
                          /a:d (It show you only directories in the list)
                         /a:h (Only show you hidden files and subdirectories)
                          /a:s (Only show you system files and subdirectories)
                          /a:r (Only show you read-only files)

q) pause
       Basically, the command is used in batch files to stop running a command without current user permission. it only gives a message 'Press any key to continue . . .' when it is run.
          Syntax: pause
                       pause>nul (It hides 'Press any key to continue . . .' message)

Post a Comment