\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{solsolsol} \pdfinfo{ /Title (cmd.pdf) /Creator (Cheatography) /Author (solsolsol) /Subject (CMD 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}{730808} \definecolor{LightBackground}{HTML}{FAF7F7} \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{CMD Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{solsolsol} via \textcolor{DarkBackground}{\uline{cheatography.com/32070/cs/9824/}}} \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}solsolsol \\ \uline{cheatography.com/solsolsol} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 13th November, 2016.\\ 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{multicols*}{3} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DIR {[}path{]} {[}/A:attrib{]} {[}/O:sort{]} {[}opt{]}}} \tn % Row 0 \SetRowColor{LightBackground} path & display specific folder (c:\textbackslash{}...) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} /A & :H(iden) :D(folder) :A(ll)... \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} /O & :N :S :E(xt) :D(ate) \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} options & /S(all sub fold)/B(que le nom) \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{DIR abcd* /s /b}}\{\{nl\}\}search for filename starting with abcd in current and all subs \& display path only} \tn % Row Count 10 (+ 3) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{DIR *abcd* /s /b}}\{\{nl\}\}search for filenames containing abcd in current and all subs \& display path only} \tn % Row Count 13 (+ 3) % Row 6 \SetRowColor{LightBackground} {\bf{DIR *.bat}} & search for *.bat files \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.04517 cm} x{3.93183 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{ATTRIB {[}+attr | -attr{]} {[}path{]}\textbackslash{}file {[}opt{]}}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\emph{DIR-like qui display les fichiers + leurs attrib.}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ATTRIB & {\emph{display {[}Attribs{]} {[}path of file{]}}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {[}+X | -X{]} & {\emph{set attrib:}} R(eadOnly),H(idden) \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{/S {\emph{set matching file in current and all sub fol}}} \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} /D & {\emph{process folder as well}} \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.63781 cm} x{2.33919 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{TYPE {[}PATH{]}\textbackslash{}random.txt (MORE)}} \tn % Row 0 \SetRowColor{LightBackground} Display text file & .txt .py .c ... \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{MORE is TYPE in better} \tn % Row Count 2 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.39356 cm} x{3.58344 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{MD nomfichier (MKDIR)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Crée un nouveau fichier} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} MD do re mi & crée ces 3 fichier dans le CD \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} MD {[}path{]}\textbackslash{}re & crée le fichier re dans {[}path{]} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} MD \textbackslash{}do\textbackslash{}re\textbackslash{}mi & crée l'arbo ..\textbackslash{}do\textbackslash{}re\textbackslash{}mi \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.44333 cm} x{3.53367 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{RD nomfichier (RMDIR)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Delete folder} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} RD \textbackslash{}do\textbackslash{}re\textbackslash{}mi & del mi in ..\textbackslash{}do\textbackslash{}re\textbackslash{}mi \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} RD /S \textbackslash{}do & after asking, del folders tree \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{COPY (files not folders)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{\{\{ac\}\}COPY = Copy \& past}}\{\{nl\}\}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{COPY src.doc newfile.doc}}\{\{nl\}\}Copy a file in the current folde} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{COPY src.txt c:\textbackslash{}somwhere\textbackslash{}else\textbackslash{}new.txt}}\{\{nl\}\}Copy from location to smhr else} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{COPY c:\textbackslash{}temp\textbackslash{}src.txt c:\textbackslash{}doc\textbackslash{}new.txt}}\{\{nl\}\} Copy from some folder to another folder} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{COPY c:\textbackslash{}mywork*.doc}}\{\{nl\}\} Copy all the *.doc into current directory} \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{COPY d:\textbackslash{}work\textbackslash{}oldfile.wp}}\{\{nl\}\}Copy to current, keep smpe fname} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{COPY {\bf{"c:\textbackslash{}bull shit\textbackslash{}calu ca va.txt"}}} \tn % Row Count 12 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{If spaces in names use quotes " "} \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.9908 cm} x{2.9862 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DEL {[}path{]}\textbackslash{}file}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\emph{Delete one or more files}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} DEL {[}path{]}\textbackslash{}do.txt & {\emph{del do.txt in {[}path{]}}} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{DEL {[}path{]}\textbackslash{}do.txt {[}path{]}\textbackslash{}re.txt {[}path{]}\textbackslash{}mi.txt\{\{nl\}\}{\emph{del do.txt, re.txt and mi.txt (can be != loc)}}} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} DEL /S c:\textbackslash{}test & {\emph{del all files in ..\textbackslash{}test}} \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{MOVE (folders or file)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{\{\{ac\}\}MOVE = cut \& past}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{MOVE oldfile.wp newfile.doc}}\{\{nl\}\}In the current folde} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{MOVE c:\textbackslash{}temp\textbackslash{}old.wp c:\textbackslash{}work\textbackslash{}new.doc}}\{\{nl\}\}from specific place to antoher} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{MOVE c:\textbackslash{}temp\textbackslash{}oldfile.wp}}\{\{nl\}\}move the file to current (keep same fname)} \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.9908 cm} x{2.9862 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{create/manip text files (txt,py,c...)}} \tn % Row 0 \SetRowColor{LightBackground} type NUL\textgreater{}new.txt & {\emph{make empty new txt file}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} echo bla\textgreater{}new.txt & {\emph{make new.txt with bla}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} echo bla\textgreater{}\textgreater{}old.txt & {\emph{add "bla" to old.txt}} \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{SET}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Display, set or remove CMD env var. Changes made with SET will remain only for the duration of the current CMD session.} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{c:\textbackslash{}\textgreater{}{\bf{SET}} var=poke\{\{nl\}\}c:\textbackslash{}\textgreater{}echo \%var\%\{\{nl\}\}{\bf{poke}}} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\{\{bt\}\}c:\textbackslash{}\textgreater{}{\bf{SET}} var=c:\textbackslash{}test\{\{nl\}\}c:\textbackslash{}\textgreater{}echo \%var\%\{\{nl\}\}{\bf{c:\textbackslash{}test}}\{\{nl\}\}c:\textbackslash{}\textgreater{}cd \%var\%\{\{nl\}\}{\bf{c:\textbackslash{}test\textgreater{}\_}}} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \{\{bt\}\} & \{\{bt\}\}/A=opérations \tn % Row Count 9 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{SET /A}} nb={\bf{3}}\{\{nl\}\}{\bf{SET /A}} nb=\%nb\%+{\bf{1}}\{\{nl\}\}echo \%nb\% \{\{fa-long-arrow-right\}\} {\bf{4}}} \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} \{\{bt\}\} & \{\{bt\}\}/P=prompt user \tn % Row Count 12 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{SET /P}} var={[}prompt string{]}} \tn % Row Count 13 (+ 1) % Row 7 \SetRowColor{white} \{\{bt\}\} & \{\{bt\}\} divers: \tn % Row Count 14 (+ 1) % Row 8 \SetRowColor{LightBackground} {\bf{SET}} var=one two & OK \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.83689 cm} x{2.14011 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Redirection}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{cmd \textgreater{} filename}}\{\{nl\}\}dir\textgreater{}new.txt & redirect cmd output\textgreater{}file\{\{nl\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{cmd \textgreater{}\textgreater{} filename}} & append into a file \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{cmd \textless{} filename}}\{\{nl\}\}{\bf{sort\textless{}rand.txt}} & \{\{nl\}\}sort file \& print result \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{cmdA \& cmdB}} & run cmdA then cmdB \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{cmdA \&\& cmdB}}\{\{nl\}\} run cmdA, if it suceeds then run cndB} \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{cmdA || cmdB}}\{\{nl\}\} run cmdA, if it fails then run cmdB} \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{cmdA \&\& cmdB || cmdC}}\{\{nl\}\} If cmdA succeeds run cmdB, if it fails cmdC} \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Arguments/Parametres (batch)}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Utile pour les scriptes avec paramètres} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{c:\textbackslash{}\textgreater{}printVar.bat {\bf{viande rouge}}\{\{nl\}\} viande rouge\{\{nl\}\}c:\textbackslash{}\textgreater{}\_ \{\{nl\}\} {\emph{le fichier batch contient:}}\{\{nl\}\} {\bf{set}} arg1={\bf{\%1}} \{\{nl\}\}{\bf{set}} arg2={\bf{\%2}} \{\{nl\}\}{\bf{echo}} \%arg1\% \%arg2\%} \tn % Row Count 5 (+ 4) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\%0-9} \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comparaisons}} \tn % Row 0 \SetRowColor{LightBackground} \{\{ac\}\}{\bf{NEQ}} (!=) & \{\{ac\}\}{\bf{EQU}} (==) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \{\{ac\}\}{\bf{LSS}} (\textless{}) & \{\{ac\}\}{\bf{LEQ}} (\textless{}=) \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \{\{ac\}\}{\bf{GTR}} (\textgreater{}) & \{\{ac\}\}{\bf{GEQ}} (\textgreater{}=) \tn % Row Count 3 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Divers}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{REM comment...}} & comment \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{date /t}} & display date \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{time /t}} & display time \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} {\bf{cls}} & clear screen \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{@echo off}} (batch) & turn off print of each line \tn % Row Count 7 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{set /A n=\%random\% \%\%100 +1}}\{\{nl\}\}n=random n {[}1;100{]}} \tn % Row Count 9 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{FINDSTR}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{FINDSTR "Joe" Contacts.txt}}\{\{nl\}\} recherche la str {\bf{Joe}} dans {\emph{Contacts.txt}}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{FINDSTR /C:"Joe Poulet" Contacts.txt}}\{\{nl\}\} "/C:" n'est pas une adresse c'est une option (inclue l'espace dans la recherche de str)} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{FINDSTR /S /I "work" *.* }}\{\{nl\}\}search in every file and filename in current and subs for the word {\bf{work}}} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{OPTIONS:}} {\bf{/S}}(search in subs){\bf{ /I}}( ignore case)\{\{nl\}\} {\bf{/A}}:2f (filenames in colour (2f is the colour))} \tn % Row Count 11 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Precurseurs}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{setlocal EnableDelayedExpansion}}\{\{nl\}\}set i=2\{\{nl\}\}echo \%elem\{\%i\%{]}\%\{\{nl\}\}Doesn't give the desired result because it means: show the value of the elem {[}variable, followed by i, followed by the value of the {]} variable. To solve this problem you must use Delayed Expansion: Enclose index variables in percent symbols, and enclose the array elements in exclamation marks:} \tn % Row Count 8 (+ 8) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{set elem{[}1{]}=First element\{\{nl\}\}set elem{[}2{]}=Second one\{\{nl\}\}set elem{[}3{]}=The third one\{\{nl\}\}set i=2\{\{nl\}\}echo !elem{[}\%i\%{]}!} \tn % Row Count 11 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{setlocal EnableExtensions}}} \tn % Row Count 12 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{ex1 creevar.bat {[}nomvar{]} {[}valvar{]}}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{@echo off \newline setlocal EnableDelayedExpansion \newline if "2"=="" goto erreur \newline set \%1==\%2 \newline goto reussi \newline :erreur \newline echo parametre manquant \newline goto fin \newline :reussi \newline echo variable definie \newline set\%1 \newline echo la variable \%1 est definie et vaut !\%1! \newline :fin} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{ex2 loop print liste}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{@echo off \newline for /L \%\%i IN (1,1,10) do echo \%\%i} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{ex3 affiche nombres entre 1 et N}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{@echo off \newline :debut \newline set /P saisie=nombre plus grd que 0 svp: \newline set /A valeur=\%saisie\% \newline if \%valeur\% LEQ 0 goto erreur \newline for /L \%\%i IN (1,1,\%valeur\%) DO echo \%\%i \newline goto fin \newline :erreur \newline echo plus grd que 0 \newline goto debut \newline :fin} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{ex 4 guess number}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{@echo off \newline set /A n=\%random\% \%\%100 + 1 \newline set essais=0 \newline :boucle \newline echo. //empty line \newline set /A essais=essais+1 \newline set /P m="{[}\%essais\%{]} nb entre 1 et 100:" \newline if \%m\%==\%n\% goto trouve \newline if \%m\%=={[}?{]} goto abandon \newline if \%m\%LSS\%n\% echo \%m\% trop petit \newline if \%m\%GTR\%n\% echo \%m\% trop grd \newline goto boucle \newline :trouve \newline echo gg \%m\% est la bonne reponse \newline goto fin \newline :abandon \newline echo Abandon. Le nm etait: \%n\% \newline :fin} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Ex 5 disp nb entre 1 et n\&carre\&cube}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{@echo off \newline setlocal EnableDelayedExpansion \newline setlocal EnableExtensions \newline :debut \newline set /P saisie=n plus grd que 0: \newline set /A valeur=\%saisie\% \newline if \%valeur\% LEQ 0 goto erreur \newline for /L \%\%i in (1,1,\%valeur\%) do ( \newline set /a carre=\%\%i {\emph{ \%\%i \newline set /a cube=!carre! }} \%\%i \newline echo \%\%i !carre! !cube! \newline ) \newline goto fin \newline :erreur \newline echo un nb + grd que 0 \newline goto debut \newline :fin} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{ex6 tri d'une série de mots}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{@echo off \newline setlocal EnableDelayedExpansion \newline setlocal EnableExtensions \newline echo "Explications" \newline set nombre\_mots=1 \newline if exist mots.txt del mots.txt \newline :saisie \newline set mots= \newline set /P mots="{[}\%nombre\_mots\%{]} " \newline if "\%mots\%" == "" goto fin\_saisie \newline echo \%mots\% \textgreater{}\textgreater{} mots.txt \newline set /A \seqsplit{nombre\_mots=nombre\_mots+1} \newline goto saisie \newline :fin\_saisie \newline echo. \newline echo ===Liste entree au clavier=== \newline type mots.txt \newline echo ===Liste triee============ \newline sort mots.txt \newline echo ===Listre triee inv ======== \newline sort /r mots.txt} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{ex7 recherche avancée en fonction param à l'exec}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{setlocal EnableDelayedExpansion \newline setlocal EnableExtensions \newline echo Ligne de commande: \%0 \%* \newline if "\%2"=="" goto erreurParam //verification para \newline if "\%1"=="" goto erreurParam //'' \newline set dossier=\%1 \newline if exist \%dossier\%NUL goto dossier\_existe \newline set dossier=\%1\textbackslash{} \newline if exist \%dossier\%NUL goto dossier\_existe \newline goto erreur\_dossier \newline :dossier\_existe \newline echo Scanning ... \newline dir /S /B \%dossier\%\textasciicircum{}\%2 \textgreater{}liste.txt \newline echo Repertoire: \%dossier\% \newline echo Fichier: \%2 \newline Liste des fichiers trouves: \newline type liste.txt \newline echo Nombre de fichiers: \newline type liste.txt | find /C /V "" \newline goto fin \newline :erreur\_dossier \newline echo \%1 n'existe pas \newline goto fin \newline :erreur\_param \newline echo Parametres manquants \newline goto fin \newline :fin} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}