What is the robocopy command to copy folders and subfolders?A reliable file copy command for the Windows command line is called robocopy. It enables users to move disks, folders, and files across different locations. Robocopy hasn't undergone many alterations in the 25 years since it was first included in the Windows NT4 resource pack. However, the SMB compression is one of the new features but the usage remains the same. Robocopy is one of the greatest free applications for file copy/mirror operations since it has many amazing capabilities, such as the capacity to copy NTFS ACLs (permissions). For the following Microsoft operating systems, robocopy.exe is a third-party command that can be used.
The syntax for Windows 10 and 11:ROBOCOPY source destination [file [file]...] [options]
Source directory (server share path or drive: path).
It is a desired dictionary (Drive: path or Server Share Path).
(Names/wildcards: the default is "*.*") File(s) to copy. Copy options:
Subdirectories should be copied, but not empty ones.
It is used to copy subdirectories, even empty ones.
The source directory tree should only be copied up to n levels.
In restartable mode, copy files.
Make backup copies of your files.
Switch to restartable mode. When access is refused, go to backup mode.
Using unbuffered I/O copy (recommended for large files).
In EFS RAW mode, copy all encrypted files.
(/COPY: DAT is the default) What to COPY for files. (Copyflags: Data (D), Attributes (A), and Timestamps (T)). O = Owner information, U= aUditing information, S = Security=NTFS ACLs.
Secure file copying is comparable to /COPY: DATS.
It is used to copy all file information (corresponding to /COPY: DATSOU).
No file information is copied (helpful with /PURGE).
Improve file security for all files, even those that were skipped.
The file time for all files should be fixed, including skipped files.
If the destination files or directories are gone from the source, delete them.
/E plus /PURGE are the equivalent of mirroring a directory tree.
Files should be moved (deleted from the source after copying).
Files and directories should be moved (deleted from the source after copying).
It is used to add the specified properties to copy files.
It is used to take the specified properties out of duplicated files.
It is used to create directory trees and files with zero length.
It is used to generate the final files utilizing only 8.3 FAT file names.
It disables the support for very long paths (more than 256 characters).
Keep an eye on the source; rerun when more than n changes are visible.
Watch the source; if anything changes, run it again in m minutes.
Run hours are the window of time within which fresh copies may be started.
It is used to check the run hours for each file, rather than for each pass.
The inter-packet gap (ms), which releases bandwidth on slow lines.
Junctions should be copied as junctions rather than as the junction targets.
Use n threads to perform multi-threaded copying (default 8). At least one and no more than 128 must be entered as n. The /IPG and /EFSRAW options do not work together with this option. You can redirect output using the /LOG option for improved performance.
The default value for what to copy for directories is /DCOPY: DA. (Copyflags: Data, Attributes, Timestamps, EAs, and Skip alternative Data Streams).
No directory information is copied (the default /DCOPY: DA is complete).
Without utilizing the Windows Copy Offload technique, copy files.
If appropriate, request network compression while transferring files. Options for Copy File Throttling :
n [KMG] bytes is the requested maximum I/O size per read/write cycle.
The number of [KMG] bytes per second for the requested I/O rate.
n [KMG] bytes is the file size threshold for throttling (see Remarks). Choices for file selection :
Just the files with the archive property set should be copied.
Reset the property and copy just the files that have it set to "archive".
Do not include any files unless at least one of the following characteristics is specified.
A file will be excluded if any of the above properties are set.
Files with the provided names, paths, or wildcards will be excluded.
Folders with the specified names or paths will be excluded.
It excludes files that have been modified.
It excludes more recent files.
Older files should be excluded.
It excludes supplementary folders and files.
Leave out any lone files and directories.
It comprises the same files.
Modified files should be included.
Files more than n bytes will be ignored as the maximum file size.
It excludes files with a size of n bytes or less.
The files older than n days/date are excluded due to a maximum file age.
It excludes files that are less than n days/date old as a minimum.
The files with a maximum last access date of n are excluded.
Exclude files used after n days from the minimum last access date. (If n 1900, n is equal to the number of days; else, n is the date, in the format YYYYMMDD).
Think of FAT file timings (2-second granularity).
Make up for DST time variations by one hour.
It excludes junction points and symbolic links (both for files and folders).
Directories and junction points should not have symbolic connections.
File symbolic links should be excluded.
It contains updated files (differing change times). Retry options :
Retries per failed copy are set to 1,000,000 by default.
There is a 30-second waiting period between trials by default.
It is used to save the default values for /R:n and /W:n in the registry.
It is used to hold off until share names are specified (retry error 67).
It is used to the copy pause and resume feature while operating in low free space mode (see Remarks).
The floor size in n [K: kilo, M: mega, G:giga] bytes, and the /LFSM command. Logging options :
Do not copy, timestamp, or remove any files; just list them.
Not just the chosen ones but any additional files as well.
It is used to create output that is verbose, and displays skipped files.
Timestamps from the source file should be included in the result.
It includes file names with their full paths in the output.
It displays sizes in bytes.
Do not log file sizes if there is no size.
Do not log file classes if there is no class.
Do not log file names or a file list.
Do not log directory names; do not provide a directory list.
Do not show the copied % if there is no progress.
It displays the copied files' predicted time of arrival.
The LOG file as the status output (overwrite existing log).
The LOG file as the status output (append to existing log).
It creates a UNICODE log file as the output status (overwrite existing log).
It creates a UNICODE log file as the output status (append to existing log).
It creates a log file and output it to a console window.
Not a job header.
There is no position description.
It is used to show the output in the UNICODE format. Job options:
The named job file's parameters should be used.
It is used to the specified job file, save the parameters.
The command line has been processed, exit (to view parameters).
There is no source directory mentioned.
There is no designated destination directory.
Add the files listed below. Formerly, using /PURGE or /MIR on the volume's root directory made robocopy perform the specified operation to files inside the System Volume Information directory as well. It is no longer true. If /PURGE or /MIR is supplied, robocopy skips any files or directories with those names in the top-level source and destination directories of the copy session. The classification of modified files only applies when the source and destination filesystems (such as NTFS) support change timestamps and the source and destination files have different change timings. By default, some files are not copied; enter /IM to include them. The/DCOPY: E flag demands extended attribute copying for directories. It should be noted that robocopy currently keeps on even if the EAs for a directory cannot be duplicated. /COPYALL does not contain this flag either. Robocopy is asked to run in "low free space mode" by using the /LFSM command-line option. While in that mode, file copying would suspend robocopy anytime the destination volume's free space would drop below a predetermined "floor" value, which can be explicitly defined by the LFSM:n[KMG] variant of the flag. Ten percent of the size of the destination volume is used as the floor if /LFSM is supplied without a floor value. The commands /MT, /EFSRAW, /B, and /ZB do not work in low free space mode. The syntax for Windows 8 and earlier :ROBOCOPY source destination [file [file]...] [options]
Source directory (server share path or drive: path).
It is a desired dictionary (Drive: path or Server Share Path).
To duplicate the specified file(s) (names/wildcards: the default is "*.*"). Copy options :
Subdirectories should be copied, but not empty ones.
Copy every subdirectory, even the empty ones.
Only the top n levels of the source directory tree should be copied.
It is used to copy files in restartable mode.
It makes backup copies of your files.
It employs the restartable mode. When access is blocked, go to backup mode.
Every encrypted file should be copied in EFS RAW mode.
(/COPY: DAT is the default) What to COPY for files. (Copyflags: Data (D), Attributes (A), and Timestamps (T)). O=Owner information, U=aUditing information, S=Security=NTFS ACLs.
COPY the timestamps in the directory.
Secure file copying is comparable to /COPY: DATS.
The equivalent of /COPY: DATSOU is to copy the entire file information.
No file information is copied (helpful with /PURGE).
It improves file security for all files, even those that were skipped.
All file timings should be fixed, even those for skipped files.
If the destination files or directories are gone from the source, delete them.
/E plus /PURGE is the equivalent of mirroring a directory tree.
Files should be moved (deleted from the source after copying).
Files and directories should be moved (deleted from the source after copying).
Files copied will now have the specified properties.
Take the specified properties out of duplicated files.
Only create directory trees and files with zero length.
It generates the final files utilizing only 8.3 FAT file names.
It disables the support for very long paths (more than 256 characters).
Keep an eye on the source; rerun when more than n changes are noticed.
Keep an eye on the source; if anything changes, run it again in m minutes.
Run hours - the window of time during which new copies may be initiated.
For each file, rather than for each pass, check the run hours.
The inter-packet gap (ms), which releases bandwidth on slow lines.
It replicate symbolic connections instead of the target.
It makes n-thread multi-threaded copies (default 8). The value of n must be at least one and no more than 128. The /IPG and /EFSRAW options are incompatible with this one. For improved performance, use the /LOG option to redirect output. File Selection options:
Just the files with the archive property set should be copied.
It is used to reset the property and copy just the files that have it set to "archive."
It does not include any files unless at least one of the following characteristics is specified.
A file will be excluded if any of the above properties are set.
It excludes files with the specified wildcards, paths, or names.
It disallows folders with the specified names or paths.
Leave out updated files.
Exclude more recent files.
Leave out older files.
It excludes supplementary folders and files.
Delete lone files and folders.
Add the same files.
Modified files should be included using this command.
Files more than n bytes will be ignored as the maximum file size.
Files with a size of n bytes or less will be excluded.
Files older than n days/date are excluded due to a maximum file age.
Files must be at least n days or more old to be included.
Files with a maximum last access date of n are excluded.
Exclude files used after n days from the minimum last access date. (If n 1900, n is equal to the number of days; else, n is the date, in the format YYYYMMDD).
Junction points are not included. (Usually included by default).
Think of FAT file timings (2-second granularity).
It is make up for DST time variations by one hour.
Directory junction points should be excluded.
File junction locations should be excluded. Retry options :
Retry counts for unsuccessful copies are set to 1,000,000 by default.
There is a 30-second waiting period between trials by default.
It saves the default values for /R:n and /W:n in the registry.
Hold off until share names are specified (retry error 67). Logging options:
Don't copy, timestamp, or remove any files; just list them.
Report all additional files, not just the ones you chose.
It is used to create output that is verbose, and displays skipped files.
Timestamps from the source file should be included in the result.
It includes file names with their full paths in the output.
Display sizes in bytes.
Do not log file sizes if there is no size.
Do not log file classes if there is no class.
Do not log file names or a file list.
Do not log directory names if no directory list is provided.
Don't show the percentage copied if there is no progress.
It displays the copied files' predicted time of arrival.
The LOG file as the status output (overwrite existing log).
The LOG file as the status output (append to existing log).
Create a UNICODE log file as the output status (overwrite existing log).
Create a UNICODE log file as the output status (append to existing log).
Create a log file and output it to a console window.
Zero job header.
No job description.
Output is in UNICODE format. Job options :
The named job file's parameters should be used.
Save the parameters to the specified job file.
After processing the command line, exit (to view parameters).
There is no source directory mentioned.
There is no designated destination directory.
Add the files listed below. Examples of robocopy :robocopy c:\hope c:\hope2 *.txt Any.txt file in this first example would be copied from the hope directory into the hope2 directory. Every time you want to copy a single file or many files rather than an entire directory, the file must be supplied after the destination directory. robocopy c:\hope c:\hope2 In the aforementioned illustration, the robocopy command would copy every file (as opposed to directories) from the hope directory to the hope2 directory. robocopy c:\hope c:\hope2 /e The hope directory and the hope2 directory both get all of their files and folders-including empty ones-copied over. robocopy c:\hope c:\hope2 /MIR This example purges any files in the hope2 directory that don't exist in the hope directory while mirroring the contents of c:hope into c:hope2. Because the /mir switch deletes files that do not match those in the destination directory, use it with caution. robocopy \\computer\hope C:\hope2 The next step in this example would be to copy any files located in the hope directory on the network computer known as the computer to the hope2 directory on the current computer. Next TopicWhat is a Device Name |