Use the Robocopy command with the /MOVE flag and a specific file filter to search subdirectories for MKV files and transfer them to a destination folder. This approach efficiently organizes game recordings by moving only the target media while preserving the directory structure, ensuring that your library remains tidy without manual intervention or complex scripting.
Understanding Robocopy Syntax
Robocopy (Robust File Copy) is a powerful command-line utility included in Windows Server and modern Windows client versions. It offers far more control than the standard
COPY or
XCOPY commands. To achieve the goal of moving specific files from subdirectories, you need to combine several switches. The core syntax follows this pattern:
robocopy source destination [file] [options].
The most critical switch for your use case is
/MOVE. Unlike
/COPY which duplicates files,
/MOVE copies the files and then deletes them from the source after successful transfer. This is essential for organizing folders where you want to remove the original clutter. You must also specify the file mask, such as
*.mkv, to ensure only video clips are targeted. Without this filter, Robocopy might move every file, including logs or configuration data, which could break your application settings.
Constructing the Command
To execute the operation, open Command Prompt or PowerShell. Navigate to a directory where you have write permissions, or run the tool as an administrator if your source folder requires elevated privileges. The basic command structure looks like this:
robocopy "C:\Path\To\SourceFolder" "D:\Path\To\DestinationFolder" *.mkv /MOVE /S
Let's break down each component. The first argument is the source path, enclosed in quotes to handle spaces. The second is the destination path. The third argument,
*.mkv, tells Robocopy to only process files ending with that extension. The
/MOVE flag ensures deletion after copying. The
/S flag is crucial because it instructs Robocopy to copy subdirectories, excluding empty ones. If you omit
/S, Robocopy will only look at files directly inside the root source folder, ignoring all nested game recording directories.
For better performance and logging, consider adding the
/LOG switch. This creates a text file detailing what was copied, moved, or skipped. This is particularly useful when dealing with large libraries of game clips, as it provides a record of the operation for troubleshooting. See our guide on interpreting the
Robocopy Command Report to understand the output codes and verify success.
Handling Permissions and Errors
When moving files across different drives or network shares, you may encounter access denied errors. Robocopy preserves file attributes, timestamps, and security descriptors by default. If the destination drive has stricter permissions, you might need to add the
/R:1 and
/W:1 flags to reduce retries and wait times, preventing the command from hanging on inaccessible files. Additionally, if you face issues where files appear locked, check our article on
Folder in use, although it isn't to resolve potential locking conflicts.
It is also important to note that Robocopy does not move hidden files or system files unless explicitly told to do so. Since game recordings are typically visible user data, this default behavior is usually desirable. However, if you accidentally move a configuration file, you can restore it from the destination before the source deletion occurs, provided you haven't already closed the command prompt window.
Alternative Approaches
While Robocopy is excellent for batch operations, some users prefer graphical interfaces or scripting languages. PowerShell offers similar capabilities with cmdlets like
Move-Item combined with
Get-ChildItem. This method allows for more complex logic, such as moving files based on age or size. For those interested in automating this process further, refer to our comprehensive guide on using
Powershell Script to Move Files.
Another common pitfall is creating duplicate folder structures if the destination already contains similar paths. Robocopy handles this gracefully by merging directories, but infinite duplication can occur if used incorrectly with recursive options. Ensure you are not running the script in a loop without proper exit conditions. Learn how to avoid these structural issues by reading about
Avoiding Infinite Subfolder Duplication with Robocopy.
Frequently Asked Questions
Can Robocopy move files to a different drive letter?
Yes, Robocopy works seamlessly across different physical drives and partitions. Just ensure the destination path is valid and has sufficient storage space. The
/MOVE flag will delete the source files once they are successfully written to the new drive.
What happens if a file is currently open by another program?
If a file is locked, Robocopy will skip it and log the error. By default, it retries three times with a five-second wait. You can adjust this using
/R:n and
/W:n. Ensure no recording software is actively writing to the MKV files during the move.
Does Robocopy preserve the folder structure?
Yes, when using the
/S or
/E flags, Robocopy recreates the directory hierarchy in the destination. This means your game clips will remain organized in their respective subfolders rather than being dumped into a single flat folder.
How do I preview the move without actually deleting source files?
Replace the
/MOVE flag with
/COPYALL or simply omit it to perform a standard copy. Run the command first to see the summary report. Once verified, add
/MOVE back to execute the actual deletion of the originals.
Can I use wildcards other than *.mkv?
Absolutely. You can use patterns like
*.mp4,
*.avi, or even multiple extensions like
*.mkv *.mp4. This flexibility allows you to consolidate various video formats from your gaming library into one centralized location.