How To Rename A File On The Command Line

Table of contents:

How To Rename A File On The Command Line
How To Rename A File On The Command Line

Video: How To Rename A File On The Command Line

Video: How To Rename A File On The Command Line
Video: How to Rename the File using command prompt 2024, November
Anonim

The command line is a powerful tool that allows you to perform any operations with files stored on the system. When working through the terminal, it is often necessary to make basic transformations - to rename a document or move it to another directory. For this, the appropriate commands are used.

How to rename a file on the command line
How to rename a file on the command line

Instructions

Step 1

Open a command prompt window. To do this, open the Start menu and go to the All Programs section. In the proposed list, select "Standard" - "Command line". You can also download the utility by launching Start and manually entering Command and then selecting the appropriate result.

Step 2

A terminal window will appear, in which you will need to enter all the commands. Place the cursor at the top of the window. Then you need to define the full address before the file you want to rename. To do this, through the graphical interface, right-click on the target document, and in the menu that appears, click "Properties". The line "Location" will contain the full path of the document, which will need to be specified in the command line.

Step 3

Go back to the terminal and enter the query:

rename drive: path_to_file / source_file_name desired_file_name

In this case, "disk" is the name of the logical partition on which the document is located. The file path is a sequence of folders that contains the desired document named "original_file_name". Desired_file_name matches the name you want to give the document.

Step 4

For example, there is a document named file.txt, which is located in the "Downloads" folder of the user Sasha of the system. To rename it to otchet.txt, you will need to enter the following query at the command line:

rename C: / Users / Sasha / Downloads / file.txt otchet.txt

Step 5

After entering the command, press Enter and wait for the operation to complete. If no errors were displayed while executing the command, then the procedure was completed correctly and the renaming was completed successfully.

Step 6

On the command line, you can rename and move the document at the same time. This operation is done using the move command, which has the syntax:

move path_to_source_file path_to_new_directory.

Recommended: