\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{PeterCeeAU} \pdfinfo{ /Title (robocopy-by-example.pdf) /Creator (Cheatography) /Author (PeterCeeAU) /Subject (Robocopy By Example Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{663133} \definecolor{LightBackground}{HTML}{F5F2F2} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Robocopy By Example Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{PeterCeeAU} via \textcolor{DarkBackground}{\uline{cheatography.com/58333/cs/15470/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}PeterCeeAU \\ \uline{cheatography.com/peterceeau} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 10th July, 2022.\\ Updated 16th April, 2018.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Reference}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{\seqsplit{http://ss64.com/nt/robocopy.html}% Row Count 1 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.181 cm} x{12.089 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Options Summary}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{17.67cm}}{{\bf{Source options}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `/E` & copy subfolders including empty subfolders \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} `/COPYALL` & copy ALL file info (DATSOU) \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{{\bf{Copy options}}} \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} `/L` & list only - don't actually copy \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} `/R:n` & number of retries, default is 1 million \tn % Row Count 9 (+ 2) % Row 6 \SetRowColor{LightBackground} `/W:n` & wait time, default is 30 seconds \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{{\bf{Destination options}}} \tn % Row Count 12 (+ 1) % Row 8 \SetRowColor{LightBackground} `/MIR` & mirror - tend to avoid using \tn % Row Count 13 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{{\bf{Logging options}}} \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} `/NP` & no progress displayed, i.e. no \%age copied \tn % Row Count 16 (+ 2) % Row 11 \SetRowColor{white} `/LOG:file` & overwrite log file \tn % Row Count 17 (+ 1) % Row 12 \SetRowColor{LightBackground} \seqsplit{`/LOG+:/file`} & append to log file \tn % Row Count 19 (+ 2) % Row 13 \SetRowColor{white} `/FP` & include full path of files in output \tn % Row Count 21 (+ 2) % Row 14 \SetRowColor{LightBackground} `/NFL` & no file list in log \tn % Row Count 22 (+ 1) % Row 15 \SetRowColor{white} `/NDL` & no directory list is log \tn % Row Count 23 (+ 1) % Row 16 \SetRowColor{LightBackground} `/TEE` & output to console and log file \tn % Row Count 25 (+ 2) % Row 17 \SetRowColor{white} \mymulticolumn{2}{x{17.67cm}}{{\bf{Advanced options}}} \tn % Row Count 26 (+ 1) % Row 18 \SetRowColor{LightBackground} `/XF file {[}file{]}` & exclude files listed \tn % Row Count 28 (+ 2) % Row 19 \SetRowColor{white} `/XD dir {[}dir{]}` & exclude directories listed \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{x{5.181 cm} x{12.089 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{17.67cm}}{\bf\textcolor{white}{Options Summary (cont)}} \tn % Row 20 \SetRowColor{LightBackground} `/V` & verbose output, shows skipped files \tn % Row Count 2 (+ 2) % Row 21 \SetRowColor{white} `/MT{[}:n{]}` & Multithreaded, default is 8 - don't normally use \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Requirements and Recommendations}} \tn \SetRowColor{white} \mymulticolumn{1}{x{17.67cm}}{The scripts, options, filenames are merely personal choices. \newline % Row Count 2 (+ 2) {\bf{Source}} and {\bf{Destination}} folders can be either local filesystem references (e.g.D:\textbackslash{}path\textbackslash{}to\textbackslash{}directory) or \{\{nl\}\}UNC path (e.g. \textbackslash{}\textbackslash{}Server\textbackslash{}share\textbackslash{}path\textbackslash{}to\textbackslash{}directory). \newline % Row Count 6 (+ 4) Log file suffix either {\bf{Date stamp}}, {\bf{Date and Time stamp}} or {\bf{Job Id}}. \newline % Row Count 8 (+ 2) The log file path (e.g. C:\textbackslash{}support\textbackslash{}logs\textbackslash{}) should exist. Robocopy makes a log file if it doesn't exist but does not create a log directory. \newline % Row Count 11 (+ 3) Should always use the log only (/L) option until ready to perform the copy at which point remove /L from the command options.% Row Count 14 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Base Command}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{robocopy {\emph{\textless{}source\textgreater{}}} {\emph{\textless{}destination\textgreater{}}} /COPYALL /L /E /R:1 /W:1 /FP /V /NP /TEE /LOG:C:\textbackslash{}support\textbackslash{}logs\textbackslash{}robocopy-{\emph{\textless{}suffix\textgreater{}}}.log} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Simple Batch Version}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{@echo off \newline SET SDIR={\emph{\textless{}type or paste Absolute directory path or Full UNC path\textgreater{}}} \newline SET DDIR={\emph{\textless{}type or paste Absolute directory path or Full UNC path\textgreater{}}} \newline :: File suffix either datestamp, datetimestamp or job id - uncomment as required \newline SET FILESUFFIX=\%date:\textasciitilde{}10,4\%\%date:\textasciitilde{}7,2\%\%date:\textasciitilde{}4,2\% \newline ::SET FILESUFFIX=\%date:\textasciitilde{}10,4\%\%date:\textasciitilde{}7,2\%\%date:\textasciitilde{}4,2\%-\%time:\textasciitilde{}0,2\%\%time:\textasciitilde{}3,2\%\%time:\textasciitilde{}6,2\% \newline ::SET FILESUFFIX={\emph{jobid}} \newline SET LOGFILE=C:\textbackslash{}support\textbackslash{}logs\textbackslash{}robocopy-\%FILESUFFIX\%.log \newline :: Common parameters: /L,/V,/B,/MIR, /MT:\# - add/remove as required \newline :: Remove /L to perform copy \newline SET MAIN\_OPTIONS=/COPYALL /L /E /R:1 /W:1 /FP /V /NP \newline SET FILE\_OPTIONS=/XD "RECYCLER" "System Volume Information" / \newline :: Default is to append to log file "+" \newline :: /TEE is not require if running as scheduled task \newline SET LOG\_OPTIONS=/TEE /LOG+:"\%LOGFILE\%" \newline robocopy.exe "\%SDIR\%" "\%DDIR\%" \%MAIN\_OPTIONS\% \%FILE\_OPTIONS\% \%LOG\_OPTIONS\%} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{17.67cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{17.67cm}}{\bf\textcolor{white}{Expanded Batch Version}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{17.67cm}}{@echo off \newline \newline :: After completing job, uncomment the following 2 lines so the script cannot be run accidentally \newline :: echo Script has been actioned, remove/comment 'exit command' if you really want to run \newline :: exit /b \newline \newline :: Data migration - \textless{}JOBID\textgreater{} \newline :: Source \newline :: {\emph{ S:\textbackslash{}Source\textbackslash{}path\textbackslash{}to\textbackslash{}directory \newline :: }} \textbackslash{}\textbackslash{}SOURCESERVER\textgreater{}\textbackslash{}Users\$\textbackslash{}username \newline :: {\emph{ \textbackslash{}\textbackslash{}SOURCESERVER\textgreater{}\textbackslash{}share\textbackslash{}path\textbackslash{}to\textbackslash{}location \newline :: Destination \newline :: }} D:\textbackslash{}Destination\textbackslash{}path\textbackslash{}to\textbackslash{}directory \newline :: {\emph{ \textbackslash{}\textbackslash{}DESTINATIONSERVER\textbackslash{}Users\$\textbackslash{}username \newline :: }} \textbackslash{}\textbackslash{}DESTINATIONSERVER\textbackslash{}share\textbackslash{}path\textbackslash{}to\textbackslash{}location \newline \newline SET JOB=JOBID \newline :: change from "listonly" to run robocopy command \newline SET TYPE=listonly \newline ::SET TYPE=run \newline :: Either host could be \%computername\% for more flexibility \newline SET SHOST=SERVERNAME \newline SET DHOST=SERVERNAME \newline \newline :: SET ISOFORMAT=time || SET ISOFORMAT=date \newline SET ISOFORMAT=date \newline if \%ISOFORMAT\%==date ( \newline SET FILESTAMP=\%date:\textasciitilde{}10,4\%\%date:\textasciitilde{}7,2\%\%date:\textasciitilde{}4,2\% \newline else ( \newline SET FILESTAMP=\%date:\textasciitilde{}10,4\%\%date:\textasciitilde{}7,2\%\%date:\textasciitilde{}4,2\%-\%time:\textasciitilde{}0,2\%\%time:\textasciitilde{}3,2\%\%time:\textasciitilde{}6,2\% \newline ) \newline \newline :: If migrating user home folder set USER and then generate directories. \newline :: Otherwise can simply use static UNC or absolute paths \newline SET USER=FirstName.LastName \newline SET SDIR=\textbackslash{}\textbackslash{}\%SHOST\%\textbackslash{}Users\$\textbackslash{}\%USER\%\textbackslash{}\textless{}SRC FOLDER\textgreater{} \newline SET DDIR=\textbackslash{}\textbackslash{}\%DHOST\%\textbackslash{}Users\$\textbackslash{}\%USER\%\textbackslash{}\textless{}DST FOLDER\textgreater{} \newline :: Change drive letter as required \newline ::SET SDIR=\textbackslash{}\textbackslash{}\%SHOST\%\textbackslash{}d\$\textbackslash{}\textless{}SRC FOLDER\textgreater{} \newline ::SET DDIR=\textbackslash{}\textbackslash{}\%DHOST\%\textbackslash{}d\$\textbackslash{}\textless{}DST FOLDER\textgreater{} \newline \newline :: Note: /L is used for testing, and log filename will be appended with "-test" \newline :: LOGDIR must exist, change as appropriate \newline SET LOGDIR=C:\textbackslash{}support\textbackslash{}logs \newline if \%TYPE\%==listonly ( \newline SET \seqsplit{LOGFILE=\%JOB\%-\%FILESTAMP\%-test}.log \newline SET LOGONLY=/L \newline ) ELSE ( \newline SET \seqsplit{LOGFILE=\%JOB\%-\%FILESTAMP\%}.log \newline SET LOGONLY= \newline ) \newline \newline :: Robocopy options - for a single folder \newline :: Common parameters: /L,/V,/B,/MIR, /MT:\# - add/remove as required \newline SET MAIN\_OPTIONS=/COPYALL \%LOGONLY\% /E /R:1 /W:1 /FP /V /NP \newline SET FILE\_OPTIONS=/XD "RECYCLER" "System Volume Information" /XF \textasciitilde{}.* thumbs.db desktop.ini \newline :: Default is to append to log file "+" \newline :: /TEE is not require if running as scheduled task \newline SET LOG\_OPTIONS=/TEE /LOG+:"\%LOGDIR\%\textbackslash{}\%LOGFILE\%" \newline robocopy.exe "\%SDIR\%" "\%DDIR\%" \%MAIN\_OPTIONS\% \%FILE\_OPTIONS\% \%LOG\_OPTIONS\%} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \end{document}