Topic : Working with files using Command prompt:



Introduction:

Every computer operating system has a different mechanism for communicating commands. Windows is the well-known operating system for Microsoft machines, Mac Operating system is the Apple Operating system. Each System required a different syntax to communicate commands, although mostly all operating systems allow the same functions to be performed, even if the syntax is different.

In this tutorial, we are going to learn how to work with files using command prompt in our Windows machine.




»

QUICK SUMMARY - We are Going to Learn:



1

Create New Files:


Working with files using command prompt: InfoBrother

We can use command prompt to generate text file. There are couple of ways to create a file using the command prompt. One and easy option is to use copy con function. There are few steps to doing this. First of all, make sure we are in the directory where we want to create the file. Then enter the following command and press enter.

copy con newfile.txt

The above command will take us to a fresh line. We can create the file line by line by typing text. when we are finished, press enter to get to a new line and start typing. To finish and save the file, press Ctrl + Z and hit enter. This will save the file newfile.txtin our current directory. we can use dir command to verify the existence of the new file.

The other way to create the file is to use start notepad command. This command will open notepad and create a new file. type the following command and press enter.

start notepad newfile.txt

Above command will do two things. first if the file is already present in current working directory, it will open the file using notepad. second thing, if the file is not present in the current directory, it will allow us to create new file.




2

Open Files:


Working with files using command prompt: InfoBrother

To check the existence of the file in the directory or to make sure that using above steps, we have successfully created the file, we can use one very easy and simple option to do so. Type the path of the file in command prompt and press enter. It will open the file in default program based on the extension. if we are about to open the file from current working directory, then we just need to type the file name with extension:

newfile.txt

Above command will open the newfile.txt in notepad if the file exist in current directory. If we want to open file from another directory then we need to type complete path just like -

G:\newfile.txt



3

Read Files:


Working with files using command prompt: InfoBrother

If we want to read the contents of the files, we can use type command. Type the following command and press enter.

type newfile.txt

The Above command reads the text of the file directly into the command prompt. To read the file from another directory, we need to provide the complete path.




4

Delete Files:


Working with files using command prompt: InfoBrother

If we want to delete the files from our computer, we can use del command. Type the following command and press enter.

del newfile.txt

The Above command will delete the file from the current directory if the file exist. To delete the file from another directory, we need to define the complete path.




5

Copy Files:


Working with files using command prompt: InfoBrother

If we want to copy the text file into another directory, we can use copy command. type the following command and press enter.

copy textfile D:\InfoBrother

The Above command will copy the textfile.txt from the current directory to D:\InfoBrother. To copy a file from another directory, we need to define complete path.




6

Move Files:


Working with files using command prompt: InfoBrother

If we want to Move the text file from one directory to another directory, we can use move command. type the following command and press enter.

move textfile D:\InfoBrother

The Above command will move the textfile.txt from the current directory to D:\InfoBrother. To move a file from another directory, we need to define complete path.




7

Rename Files:


Working with files using command prompt: InfoBrother

If we want to rename the existing file, we can use ren command. type the following command and press enter.

ren old-name new-name

Ren command stands for "Rename" when we use the ren command, we must include two parameters. The first is the file we want to rename and the second is the new name for the file. we must separate the two name with space.






You like it? Other May like it too:

PLEASE SHARE






I Tried my Best to Provide you complete Information regarding this topic in very easy and conceptual way. but still if you have any Problem to understand this topic, or do you have any Questions, Feel Free to Ask Question. i'll do my best to Provide you what you need.

Sardar Omar.
InfoBrother




Advertising

Advertisement