Operating System

File Navigation with Windows Command Prompt

Although the file explorer in windows works well, occasionally it becomes necessary to create, execute, delete and move files using command prompt. This could be necessary due to a specific issue with the windows file explorer or a more deep rooted problem with windows itself. Regardless of the issue, there are a few basic commands that can help when using command prompt in this capacity.


cd/chdir: change directory. cd/ brings you to the root directory. cd.. goes up one level. chdir doesn’t parse file paths with spaces in the name

copy: This command copies a specified file to a given location. The syntax for the command is copy followed by the original file location, followed by the path that you want the file to be copied to.

del/erase: deletes a file or number of files. The command can be followed by the name of the file (e.g. del “fileName.txt”) or a file type (e.g. del *.doc). Additionally files with names beginning with or ending with a specific letter can be deleted by typing, respectively “del a*” or “del *a.*”. This command only deletes it in the sense that it is moved to the recycling bin and can be restored. To permanently delete a file precede the delete command with “type nul > filepath.fileExtension”

dir: this displays the current files and folder directly accessible from either the current directory, or the directory specified after the command.

find: searches a specific file for a given string. Example- find “jones” test.txt

md/mkdir: This command creates a new directory. There are a few different ways the command can be utilized. To create a single folder withing the current directory use “md newFolder”. To create multiple folders in the current directory use “md folderOne folderTwo folderThree”. To create a new file path that doesn’t currently exist type “md \folderOne\folderTwo\folderThree”.

move: Move is basically a copy/paste command that move a file from one location to another. The syntax is move followed by the source location followed by the target location in quotation marks.

popd/pushd: Allows the user to quickly switch between file paths. Use pushd followed by a file path to switch paths. Then to quickly switch back to the previous path call popd.

ren/rename: This command is used to rename directories. The command is followed by the directory you wish to rename, followed by the new name in quotation marks.

rd/rmdir: This allows the user to remove a directory. The command is then followed by a file path, and all folders within that path are then deleted. To delete the path itself as well precede the path with the command “/S”. To remove the display of the yes/no confirmation precede the path with the command “/Q”.

start: Allows the user to start a program (so long as the program is an executable, batch or command file). The command is followed by a title for the cmd window bar (required), the starting path and the file to be run. Any parameter that the program needs are appended at the end of the command.

tree: Displays a graphical file tree of the the specified file path, or the current drive if no path is specified.

While not a comprehensive or extensive list by any means, these commands can be some of the most useful with regards to file manipulation in command prompt, when other methods of doing so are not available.