- Команда MOVE — переименование или перемещение файлов и каталогов
- Rename file from command line [CMD]
- Errors:
- MS-DOS and Windows command line move command
- Availability
- Move syntax
- Move examples
- MS-DOS and Windows command line ren and rename commands
- Availability
- Ren and rename syntax
- Ren and rename examples
- Windows command move and rename
- Syntax
- Parameters
- Examples
Команда MOVE — переименование или перемещение файлов и каталогов
Команда MOVE используется для перемещения или переименования файлов и каталогов. Формат командной строки:
Перемещение одного или более файлов:
MOVE [/Y | /-Y] [диск:][путь]имя_файла1[. ] назначение
MOVE [/Y | /-Y] [диск:][путь]имя_папки новое_имя_папки
Параметры командной строки:
[диск:][путь]имя_файла1 — Определяет местоположение файла или файлов, которые необходимо переместить.
Назначение — Определяет новое местоположение файла. Назначение может состоять из буквы диска (с последующим двоеточием), имени папки или их комбинации. При перемещении только одного файла, можно указать и его новое имя, если хотите выполнить его одновременное переименование при перемещении.
[диск:][путь]имя_папки — Определяет папку, которую необходимо переименовать.
новое_имя_папки — Определяет новое имя папки.
/Y — Перезаписывать существующие файлы назначения без предупреждения.
/-Y — Предупреждать при перезаписи существующего файла назначения.
Ключ /Y может присутствовать в значении переменной среды окружения COPYCMD . Оно может перекрываться ключом /-Y в командной строке. По умолчанию используется предупреждение о перезаписи, если только команда MOVE не выполняется как часть пакетного файла.
move /? — отобразить подсказку по использованию команды.
move folder1 folder2 — переименовать папку с именем folder1 в folder2 в текущем каталоге.
move E:\test\folder1 E:\test\folder2 — переименование с указанием абсолютных путей.
move C:\file1.txt D:\ — переместить файл file1.txt с диска C: на диск D:
move c:\test\file1.txt D:\folder2\file2.txt — перенести файл file1.txt из каталога test диска C: в каталог folder2 диска D: под именем file2.txt
move C:\Folder1\*.* D:\Folder2\ — переместить все файлы из каталога Folder1 диска C: в каталог Folder2 диска D:
Реализация в ОС Windows данной команды не позволяет перемещать папки на другие логические диски.
move C:\folder1 C:\folder2\folder3\folder1 — переместить каталог folder1 из корня диска C: в подкаталог \folder2\folder3
При перемещении папки в несуществующий каталог он не будет создан автоматически и команда завершится ошибкой. Команда move не работает с файлами, имеющими атрибуты «скрытый » и «системный».
Rename file from command line [CMD]
We can use the command rename to rename files from windows command prompt(CMD). Find below syntax of the command with examples.
Syntax of rename command:
After executing the above command we’ll have file2.doc in the folder d:\data
Ren is alias for rename , so both refer to the same command.
Errors:
- If the files is being used by a program, then rename command fails with below error.
- You also need to have sufficient privileges to rename the file.
- Rename changes just the file name, it does not convert a file from one type to another. For example, if you rename a file from mp4 to mp3 extension, it does not change the file format. Renaming a doc file ‘mydocument.docx’ to ‘mydocument.pdf’ does not make the file readable in Acrobat Reader.
Does the command have to be executed in the root directory, or can it be done in a subdirectory that is in the root directory? Also, can a directory be renamed (EXAMPLE: renaming Dell.dir to Newname.dir)?
yes, you can run the command (for that matter, any other windows command) from any folder, it need not be root folder. And yes, ren works for directories too. There’s a separate post for this – http://www.windows-commandline.com/rename-directory-from-command-line/
this command gives repeating of filename when there are more then 40 files in the folders ?
any solution for renaming 100s of file .
i have
4299999940_M_harsha.png these type of files in several sub folders, with similar name structure(42 as first part of name, 40_M_harsha as last part of name.. in between 6digits(which may contain 42 and 40 also.in this example it has 999999))
i have to rename it as 99999..i.e, remove first and last part of file name which is common for all files in the subfolder
another examples:
4292345640_M_harsha.png -> 923456
4291424040_M_harsha.png -> 914240
could u please help
how do I rename a file by keeping the last 20 characters. I have random file names however the last 20 characters are what I want to keep. They are dates and a document ID.
filename too long cannot rename Please now setup new rename
I use, Batch Rename Files Tool. You can easily found hier BatchRenameFiles.org that allows you to quickly rename all the files in a specified directory.
Simple stuff. Been there and done that but I have a mess of files that contain a “%20” or several in the filename. I need help to sort this out. My REXX program has produced a batch file containing lines like these:
1.JPG” corn_escaLator.jpg
ren “CHOCO%
1.JPG” choco_Lady.jpg
ren “CAT%20
4.JPG” cat_wet_getting_bathed.jpg
ren “CAT%20
3.JPG” cat_burrito.jpg
ren “CAT%20
2.JPG” cat_bra.jpg
ren “CAT%20
1.JPG” cat_bite_nose.jpg
ren “BOOTY%
1.JPG” booty_cake.jpg
ren “BIRD%2
2.JPG” bird_watersLide.jpg
ren “BIRD%2
1.JPG” bird_mouth_dog.jpg
ren “BIG%20
1.JPG” big_mac.jpg
ren “BANK%2
1.JPG” bank_cake.jpg
ren “ANGEL%
Suffice to say it isn’t working as intended. I get tons of
“The system cannot find the file specified.” messages.
I prefer not to use the powershell whether I have it or not in case I need to run this in a more primitive Windows. I have tried rename instead of ren and without double quotes. I have administrator privileges.
I am running Windows7 32-bit.
GOOD, IT WORKED FOR ME
I use windows 10, and I did the steps, even in the location but it ‘couldn’t find the file specified.’ Please help.
MS-DOS and Windows command line move command
The move command allows users to transfer files or directories from one directory to another, or from one drive to another.
Availability
Today, move is an internal command that is available in the following Microsoft operating systems. When move was first introduced with MS-DOS 6.0, it was an external command that used the move.exe file up to MS-DOS 6.22.
Move syntax
Moves files and renames files and directories.
To move one or more files:
To rename a directory:
[drive:][path]file name1 | Specifies the location and name of the file or files you want to move. |
destination | Specifies the new location of the file. The destination can consist of a drive letter and colon, a directory name, or a combination. If you are moving only one file, you can also specify a destination file name, if you want the moved file to be renamed. |
[drive:][path]dirname1 | Specifies the directory you want to rename. |
dirname2 | Specifies the new name of the directory. |
/Y | Suppresses prompting to confirm you want to overwrite an existing destination file. |
/-Y | Causes prompting to confirm you want to overwrite an existing destination file. |
The switch /Y may be present in the COPYCMD environment variable. This switch may be overridden with /-Y on the command line. The default protocol is to prompt on overwrites unless MOVE command is being executed from within a batch script.
Move examples
Move the files of c:\windows\temp to the temp directory in root, this is of course assuming you have the Windows\temp directory. In this example, *.* is wildcards telling the computer every file with every extension.
If your directory name or file name has a space, it must be surrounded with quotes, otherwise you get a «The syntax of the command is incorrect.» error message. The command above would move the «computer hope» directory into the example directory contained in the same directory (current directory).
MS-DOS and Windows command line ren and rename commands
The ren and rename commands change the name of files and directories.
In earlier releases of MS-DOS, instead of using ren or rename you need to use the move command to rename directories or files.
Availability
Ren and rename are internal commands that are available in the following Microsoft operating systems.
Ren and rename syntax
Renames a file/directory or files/directories.
You cannot specify a new drive or path for the destination of a renamed file.
Ren and rename examples
Change the name of the directory «computer» to «hope.»
Rename all text files with the «.txt» file extension to files with «.bak» extension.
When renaming files using an asterisk (*) keep in mind that you can rename all files in a directory. If there are files in the current directory you don’t want renamed make your rename less greedy by adding a file extension.
Rename all files to begin with 1_. The asterisk (*) in the command above is an example of a wild character and can represent one or more characters. With only an asterisk, all file names in the current directory are renamed to have «1_» as the first two characters.
To represent or match one single character only, use the question mark (?) character instead.
Windows command move and rename
Moves one or more files from one directory to another directory.
Moving encrypted files to a volume that doesn’t support Encrypting File System (EFS) results will result in an error. You must first decrypt the files or move them to a volume that supports EFS.
Syntax
Parameters
Parameter | Description |
---|---|
/y | Stops prompting for confirmation that you want to overwrite an existing destination file. This parameter might be preset in the COPYCMD environment variable. You can override this preset by using the -y parameter. The default is to prompt before overwriting files, unless the command is run from within a batch script. |
-y | Starts prompting for confirmation that you want to overwrite an existing destination file. |
Specifies the path and name of the file(s) to move. To move or rename a directory, the source should be the current directory path and name. | |
Specifies the path and name to move files to. To move or rename a directory, the target should be the desired directory path and name. | |
/? | Displays help at the command prompt. |
Examples
To move all files with the .xls extension from the \Data directory to the \Second_Q\Reports directory, type: