CLI Commands

CLI is a very powerful tool, what it lacks in shiny buttons, it makes up for in productivity. Not for the faint of heart, but definitely for people who appreciate automating their efforts.

What Other Cool Stuff Can I Do?

Long story short - here's the full list of Windows commands as stated in Microsofts documentation.

Let's take a look at some other frequently used ones!

tree

This allows you to not only look at what's stored in the current folder, like with dir, but also shows you the underlying folders and files within those folders (all of them, so don't run this at the upper most level, like "C:").

To see the files you have to add /f which is a parameter, that's used for: "Displays the names of the files in each directory.".

Parameters allow you to customize the executed command (so developers wouldn't need to create a separate command for each action). You can look up any of the CLI command parameters in the Microsofts documentation.

echo

You can also create files with the CLI, like so:

echo "this is some text" > TextFile.txt

This will create a text file with the quoted text in it. Simple!

"this is some other text" > TextFile2.txt

Notice that you can ommit the keyword "echo" and it will work just fine.

.. but why?

Creating files with the CLI might seem strange at first, but let's say you'd like to actually see the bigger picture of the tree /f command. Like, the entire disk drive and save it for reference. You'd do it like so:

tree > TreeStructure.txt

or if you want to include files too:

tree /f > TreeStructure.txt

Now it starts making more sense. It simply outputs what would be written to the console, in the text file instead! Now you can enjoy the (hopefully) tidy representation of your file system in one file!

del

Deleting files and folders is as simple as just navigating to the folder it resides in via cd and executing:

del "file name.extension"

for example

del "UglyPictureEww.jpeg"

rmdir

You can delete folders the same way, only the command is different:

rmdir "folder name"

That only works for empty folders though, to fully clear out a folder and all of it's subfolders and items, you have to add the /s parameter.

You'd use it like this:

rmdir /s "folder name"

move

You can move files and folders to another place with this command. You can rename the file while moving it too!

So imagine you have a file structure like this:

C:\Test.
│   TextFile.txt
│
└───New folder

And you would like to move the text file into the subfolder, you'd use this:

move "TextFile.txt" "New folder"

To move it to an entirely different folder, just specify the full path in the destination argument:

move "TextFile.txt" "C:/NewTest"

To move folders, it's the same:

move "New folder" "C:/NewTest"

xcopy

You can copy stuff like this too!

xcopy TextFile.txt TextFileCopy.txt

Then just select whether you're copying a file or a folder.

Simple!