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?
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?
I know this is superlate, but just in case it helps anyone.
Used this to search all sub-folders for a .MKV file and move them to the current directory the batch file resides in.
After the move command, you have the source folder followed by the destination where the files will be moved to. The * in front of each file extension is a wildcard function that will select all of the specified filetype existing within that directory.
Also, if you can create a .bat file with these commands if you want to. To do this, paste your commands into notepad and save it as .bat instead of .txt
Then, you can double-click the file and it will execute the commands within the file each time you do. This is useful if you have any repetitive tasks that require this.
Just taking a wild stab in the dark here, but if I remember correctly DOS can handle globs and the equivalent of
mv
isMOVE
, so:MOVE C:\FOLDER1\*\*.PDF C:\FOLDER1\
{moves all files from the
newdrg
folder and its "sub-folders" to the target folderAlldrawings
, this command is for batch file operation for command line use single "%" in both the places}.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:
This shows that a wildcard does not work in paths, only for files in a single directory (e.g. C:\folder*.files). The command prompt does not operate recursively when it encounters a wildcard.
There is another way to do this in Windows Explorer (GUI, not command prompt):