- Команда MOVE — переименование или перемещение файлов и каталогов
- перенос move
- Синтаксис Syntax
- Параметры Parameters
- Примеры Examples
- Move Files with Powershell and CMD (examples)!
- The solution is quite easy to move with Powershell and / or cmd.exe files, or folders, here with examples!
- 1.) . Move the data with the command prompt (cmd.exe) 2.) . Moving the data using PowerShell! 3.) . What should I consider when move files by command line! 4.) . Overview of the MOVE commands!
- 1.) Move the data with the command prompt (cmd.exe)
- 2.) Moving the data using PowerShell!
- 3.) What should I consider when move files by command line!
- 4.) Overview of the MOVE commands!
- How to move all files with specific extension from all subdirectories to their parent using CMD?
- 11 Answers 11
- In a .bat / .cmd file:
- For direct input into a Command Prompt window (not PowerShell):
- How can I move all the files from one folder to another using the command line?
- 9 Answers 9
Команда 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 не работает с файлами, имеющими атрибуты «скрытый » и «системный».
перенос move
Перемещает один или несколько файлов из одного каталога в другой. Moves one or more files from one directory to another directory.
Перемещение зашифрованных файлов на том, который не поддерживает результаты шифрованная файловая система (EFS) (EFS), приведет к ошибке. Moving encrypted files to a volume that doesn’t support Encrypting File System (EFS) results will result in an error. Сначала необходимо расшифровать файлы или переместить их в том, который поддерживает EFS. You must first decrypt the files or move them to a volume that supports EFS.
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
/y /y | Останавливает запрос подтверждения о том, что необходимо перезаписать существующий целевой файл. Stops prompting for confirmation that you want to overwrite an existing destination file. Этот параметр может быть предустановлен в переменной среды КОПИКМД. This parameter might be preset in the COPYCMD environment variable. Эту предустановку можно переопределить с помощью параметра -y . 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 -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
Чтобы переместить все файлы с расширением XLS из каталога \Data в каталог \ Second_Q \репортс , введите: To move all files with the .xls extension from the \Data directory to the \Second_Q\Reports directory, type:
Move Files with Powershell and CMD (examples)!
The solution is quite easy to move with Powershell and / or cmd.exe files, or folders, here with examples!
1.) . Move the data with the command prompt (cmd.exe)
2.) . Moving the data using PowerShell!
3.) . What should I consider when move files by command line!
4.) . Overview of the MOVE commands!
1.) Move the data with the command prompt (cmd.exe)
At the Windows command prompt, you can move files with the move command (folder and files). For example, if you want to move a file named «text_file.xls» to the «C: \Folder1» folder , type the following command:
move test_file.xls C:\Folder1
Here, we move the file from the current working directory to C:\Folder1.
However, if you want to move from a specific folder, you must specify the full folder path, which should also be noted if the destination or source directory is stored in the folder folder. Path include spaces, must be used «» quotes (quotation marks).
move «D:\Test Folder\test_file.xls» C:\Folder1
You can also move multiple files using wildcards. In the example below, the move command moves all files with the file extension *.xls to the «C:\folder 2» directory .
move «D:\Test Folder\*.xls» «C:\Folder 2»
If executed correctly, you will see how many files have been moved!
2.) Moving the data using PowerShell!
Even with Powershell you can move files and folders! The MOVE command can also be used in the powershell console. However, this is not the Powershell home-made move command!
That would be the correct Powershell command but MOVE is much more elegant in this case
3.) What should I consider when move files by command line!
4.) Overview of the MOVE commands!
ColorConsole [Version 2.6.1001 ]
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Neno>move /?
Moves files and renames files and directories.
To move one or more files:
MOVE [/Y | /-Y] [drive:][path]filename1[. ] destination
To rename a directory:
MOVE [/Y | /-Y] [drive:][path]dirname1 dirname2
Specifies the location and name of the file
or files you want to move.
destination
Specifies the new location of the file. 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 include a filename if
you want to rename the file when you move it.
[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 may be overridden with /-Y on the command line. Default is
to prompt on overwrites unless MOVE command is being executed from
within a batch script.
You can safely use this on the following operating systems: Windows 10 Pro, Enterprise, Home, Windows 8.1, Windows 8, Windows-Server 2019, 2016, 2012, Windows 7 Basic, Professional, Starter, Ultimate and all commands for free!
How to move all files with specific extension from all subdirectories to their parent using CMD?
Folder c:\folder1 contains subfolder1 , subfolder2 , etc..
These subdirectories hold .pdf and .db files.
How can all the .pdf files be moved to c:\folder1 using the Windows command interpreter?
11 Answers 11
This worked for me:
In a .bat / .cmd file:
For direct input into a Command Prompt window (not PowerShell):
This command will copy recursively all *.pdf files from the source (and all of its subdirectories) to the target directory.
To exclude files in subdirectories omit the /r switch.
The outer for loop lists the sub-directories in the working directory, the inner for loop lists the sub-directories to move to the destination path:
This works best if DestinationPath is not a subfolder of the working directory, as it will try to move DestinationPath into itself.
To confirm the command before running it wholesale, start out just echoing the final move commands like so:
and copy/paste one of the results to run it and confirm it worked the way you expected. Then remove the echo and get moving.
There is another way to do this in Windows Explorer (GUI, not command prompt):
- Navigate to the top-level directory
- In the search box in the top-right, type *.pdf and hit search
- Select all the files and drag them to the top-level folder
- Respond to any prompts about overwriting files
10 directories. I think this is particularly useful when you have a lot of locations, even with a small # of files. – StayOnTarget Jun 5 ’19 at 21:12
I don’t think there’s a wildcard that will work on subfolders, so you want to use a loop to go through each subfolder and move *.pdf;
FOR /R [your root folder path] %%G IN (*.pdf) DO move %%G [new path]
The command after DO is inherently in its own quotes. If you anticipate spaces in your source or destination, use double quotes to encapsulate them, e.g.:
FOR /R «source folder with spaces» %%G IN (*.pdf) DO move «%%G» «dest path with spaces»
NOTE the quotes around %%G, these are required for the move command to resolve the path.
**EDIT: In response to the accepted answer, From command prompts on Windows XP and Windows 7, respectively:
How can I move all the files from one folder to another using the command line?
What is the best command to move all files from one folder to another?
I want to do this from within a batch file.
9 Answers 9
You can use move for this. The documentation from help move states:
See the following transcript for an example where it initially shows the qq1 and qq2 directories as having three and no files respectively. Then, we do the move and we find that the three files have been moved from qq1 to qq2 as expected.
will work, but you will end up with a structure like this:
If you want to move just the contents of one folder to another, then this should do it:
This command will move all the files in originalfolder to destinationfolder.
(However it wont move any sub-folders to the new location.)
To lookup the instructions for the MOVE command type this in a windows command prompt:
Lookup move /? on Windows and man mv on Unix systems
You can use the command move
robocopy seems to be the most versatile. See it’s other options in the help
use move then move
Be sure to use quotes if there are spaces in the file path:
That will move the contents of C:\Users\MyName\My Old Folder\ to C:\Users\MyName\My New Folder
OMG I Got A Quick File Move Command form CMD
1)Command will move All Files and Sub Folders into another location in 1 second .
Hint : For move all Files and Sub folders
check image
you can see that it’s before i try some other code that was not working due to more than 1 files and folder was there. when i try to execute code that is under line by red color then all folder move in 1 second.
now check this image. here Total 6.7GB data moved in 1 second. you can check date of post and move as well as Folder name.
i will soon make a windows app that will do same..