Rename Files and Folders using Batch script

Rename Files and Folders using Batch script

to rename file in Batch?

To rename any
file or folder using batch script, you have to make sure that the file or
folder which you are going to change it name is not opened or used by another

After that it is easy to rename it as the following steps:
1- Open the
notepad or any other text editor.
2- Turn the
echo command off by typing @echo off
3- Use the
command line ren followed by the file or folder
name you want to change it, then leave space and type the new file or folder
4- Save the
command lines as .bat file.
After running
the batch, the file that you want to be renamed will take the new name
directly, provided that is not opened or used by other software as mentioned
However, if the
filename after the command ren was misspelled, the command prompt will ”

The system cannot find the file specified.” And the filename will not change or alternate to the new one.

Rename the file
to data2.txt
and the folder test to Test2 using batch script

To rename and
change the filename data.txt to the new name data2.txt, the following batch code
is used
Also, to change the folder name test to the new folder
name Test2 the following batch code is used
Therefore, we can notice that there is no difference
between files and folder when it comes to rename each of them. Just following
the batch code script pattern in renaming files and folders, will lead to
update filename or folder name to the new modified one.

file or folder contain space in the name

One frequent question among a lot of batch users is; how to
change filename or folder name with more than one world and containing space between
them? The simple answer to this case, is to put filename or folder name between
the Quotes Marks “ ” and apply the renaming batch code on them like this:
“New Folder” test
Here, the folder named New Folder changed to the
new folder name test. Hence, the compound filename or folder name, that
include space, must be surrounded with the quotes “ ” in order to be recalled completely,
when applying batch script on it.


اقراء ايضا