8
1
I am using Windows 7 and I want to copy all PDF files inside a folder and inside all its subfolders in a new location. What is the command to do that?
8
1
I am using Windows 7 and I want to copy all PDF files inside a folder and inside all its subfolders in a new location. What is the command to do that?
10
Use the xcopy
command. You can go to a command prompt and type xcopy /?
to get help using it.
For your particular question, the full command would be:
xcopy c:\sourcefolder\*.pdf c:\destinationfolder\ /e
3This recreates the folder structure. – Devil's Advocate – 2016-11-01T16:37:59.150
4
If you want all the PDFs to go into one folder:
copy <source path>\*.pdf <destination path> /s
If you want to keep the original folder structure:
xcopy <source path>\*.pdf <destination path> /s
2copy
does not support the /s
switch. – Kendall Frey – 2015-10-20T13:53:00.930
3
I strongly suggest you use RoboCopy as this has a wealth of options (far beyond the list I've provided). However, as you only want to copy PDF files, use this syntax
Robocopy C:\Users C:\UserBackup *.pdf
Robocopy Syntax
ROBOCOPY source destination [file [file]…] [options]
where source is Source Directory (drive:\path or \\server\share\path), destination is Destination Directory (drive:\path or \\server\share\path) and file is File(s) to copy where names or wildcards can be specified and default is “*.*” (all files).
Robocopy Options and Switches
Copy options :
/S :: copy Subdirectories, but not empty ones.
/E :: copy subdirectories, including Empty ones.
/LEV:n :: only copy the top n LEVels of the source directory tree.
/Z :: copy files in restartable mode.
/B :: copy files in Backup mode.
/ZB :: use restartable mode; if access denied use Backup mode.
/EFSRAW :: copy all encrypted files in EFS RAW mode.
/COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
(copyflags : D=Data, A=Attributes, T=Timestamps).
(S=Security=NTFS ACLs, O=Owner info, U=aUditing info).
/DCOPY:T :: COPY Directory Timestamps.
/SEC :: copy files with SECurity (equivalent to /COPY:DATS).
/COPYALL :: COPY ALL file info (equivalent to /COPY:DATSOU).
/NOCOPY :: COPY NO file info (useful with /PURGE).
/SECFIX :: FIX file SECurity on all files, even skipped files.
/TIMFIX :: FIX file TIMes on all files, even skipped files.
/PURGE :: delete dest files/dirs that no longer exist in source.
/MIR :: MIRror a directory tree (equivalent to /E plus /PURGE).
/MOV :: MOVe files (delete from source after copying).
/MOVE :: MOVE files AND dirs (delete from source after copying).
Examples:
To use Robocopy is simple, just like how you would use Copy and Xcopy commands. For example, to copy entire folder of C:\Users to C:\UserBackup, simply type:
Robocopy C:\Users C:\UserBackup
Note: you need the \e
switch to copy all subdirectories too (which the asker specified in their question). – Lews Therin – 2017-11-10T19:50:26.680
@LewsTherin, yes... the accepted answer shows this!?!? The post above gives the OP a better understanding. I have no idea on what your point is – Dave – 2017-11-12T08:29:03.077
The accepted answer suggests using xcopy
while your answer suggests using robocopy
. Besides that, your answer is separate from the accepted answer. My point was that, for your answer to fully satisfy what was asked by OP, you needed to include the /e
switch. – Lews Therin – 2017-11-13T14:27:24.620
2
Try this (on the command line):
for /r "c:\my\source folder" %i in (*.pdf) do copy "%~fi" "c:\my\destination folder\%~nxi"
On the explorer:
..with copy-past you can drag the source folder to the new destination while pressing the ctrl key.
If this a programming question? – David Heffernan – 2013-05-08T02:49:59.077
5Open the main folder press
Ctrl
+F
, type in*.pdf
Select all the results and copy them to a new location. – Reda – 2013-05-08T04:54:39.597