If you’ve ever faced the task of aggregating all MP4 files from various subfolders into a single directory, you know how tedious it can be to do it manually. In this guide, we’ll walk through a simple one-liner command that accomplishes this task efficiently using the Windows Command Prompt.
Requirements
- A Windows operating system
- Basic familiarity with the Command Prompt
Steps
- Open Command Prompt:
- Navigate to the
Start Menu
, search forcmd
, and open the Command Prompt.
- Navigate to the
- Navigate to the Target Directory:
- Use the
cd
command to change the directory to where you’d like to copy the MP4 files. For example,
cd C:\Users\YourUsername\TargetDirectory
- Use the
- Run the One-Liner Command:
- Copy and paste the following command into the Command Prompt and press Enter.
for /r %i in (*.mp4) do copy "%i" .
Explanation
for /r
: This part of the command recursively scans through all the subdirectories of the current directory.%i
: A temporary variable that holds the full path of each MP4 file found during the scan.in (*.mp4)
: The command looks specifically for files with an.mp4
extension.do copy "%i" .
: For each file found, thecopy
command is executed to copy the file into the current directory.
Key Points to Remember
- Recursion: The
/r
flag is crucial for searching through subdirectories. - File Filtering: The
(*.mp4)
part ensures you’re only looking for.mp4
files. - Copy Operation: The
copy
command is used to duplicate the files into your current directory.