Windows Scripting Utilities Xcopy

Total Page:16

File Type:pdf, Size:1020Kb

Windows Scripting Utilities Xcopy Windows Scripting Utilities_xcopy Table of Contents xcopy ............................................................................................................................................... 2 xcopy Syntax -1 ............................................................................................................................... 3 xcopy Syntax -2 ............................................................................................................................... 5 xcopy Options -1 ............................................................................................................................. 6 xcopy Options -2 ............................................................................................................................. 9 xcopy Strings ................................................................................................................................. 12 xcopy Exclude ................................................................................................................................ 13 xcopy Examples -1 ......................................................................................................................... 14 xcopy Examples -2 ......................................................................................................................... 16 xcopy Exit Codes ........................................................................................................................... 21 ROBOCOPY .................................................................................................................................... 22 Notices .......................................................................................................................................... 24 Page 1 of 24 xcopy xcopy Extended copy A command for copying multiple files or entire directories across file systems or networks Run from the command prompt or in Batch files Great tool for exfiltration of complex directory structures or entire drives Allows for very selective copying • Include & exclude • Date modified Deprecated by robocopy starting with Vista 2 **002 So one of the tools, xcopy. Short for extended copy. Lets you do some things that the basic copy command there in the windows command line cannot do. You can do multiple files and you can do entire directories, or cross-file systems. And also cross- networks. You run this command from the command line and therefore you can put it in your Batch file. It's a great tool for this says exfiltration, which kind of sounds hacker-ish, but perhaps file transfer might be a better term with complex directory structures or even entire drives. So that's pretty powerful when you can pull the entire drive. You can be pretty selective in what you want or Page 2 of 24 what you don't want by doing some including or some excluding. And you can also base this, which is kind of nice if you're doing backups, you can base things on dates when they were last modified. Technically, it's deprecated, but they had it on Windows 7, and Windows 8, I found. So still useful and can be done, can be used, in your scripts in those Windows systems. xcopy Syntax -1 xcopy Syntax -1 xcopy source [destination] [options] source – defines the files or top level folder to copy from • The only required parameter destination – specifies location where source file or folders should be copied • If there is no destination, the folder where xcopy was run will be used • If destination directory does not exist, will prompt Use quotes “” if the path contains spaces 3 **003 So just some basic syntax. The only thing you need that's not optional is a source, wherever you're pulling your files from. The destination and the other options are Page 3 of 24 as, that says, optional. The source you just got to let it know where the file's coming from or the top level folder you want to pull from. Destination, got to make sure same thing. Let them know where you want to send it to. So xcopy, if you run it with just the source and no destination, it assumes that you want to copy it into your current folder that you're running xcopy out of. Also, if you do put a destination in and it doesn't exist or it can't find it, it'll actually prompt you for the destination or a different destination. And if your destination has spaces, you'll definitely want to put quotes around it in the path. Page 4 of 24 xcopy Syntax -2 xcopy Syntax -2 xcopy with no options • Does not copy directories • Does not copy hidden or system files • Removes read-only attribute • If run a second time will prompt for overwrite • Copies files in the temp directories and places them in c:\ 4 **004 Okay. So you can run, like I said, xcopy with no options, but there are some limitations when you do this. It will not copy directories if you do it with just the xcopy and the source location. And it won't copy any hidden or system files that are in there. So if you're trying to pull something out of, say, a, like, a system 32 or whatever. It will not pull those hidden, or system files, out. And it does remove the read- only attribute on the files that it pulls. And then, well, similar to many other copying programs, if you run it a second time it'll prompt you if you want to overwrite the files that you just copied. So it's just an example Page 5 of 24 of pulling the files out of temp and placing them into c:/ or the xcopy is located. xcopy Options -1 xcopy Options -1 [/?] – Display all options [/w] – Displays “Press any key to begin copying files(s)” [/c] – Ignore errors* [/q] – Suppresses the display of xcopy messages* [/f] – Displays source and destination file names [/l] – List only – display files that would be copied [/y] – Suppresses prompting to confirm overwrite [/k] – Retain read-only attribute on destination files [/i] – Assume the destination is a folder 5 **005 Okay. So lots and lots of switches. So I'm not going to sit here and go a, b, c for you. You can look them up. With the /?, a lot of command-line commands use the //Help or the /H or something like that. This particular xcopy uses the /? to get at it. For some reason it kind of barks at you if you do H and you do Help. So you'll want to do the /?. It'll display all of these, not just these. Just a couple that are worthy of mentioning, pointing out in detail, Page 6 of 24 is the /c, ignores errors. This is very helpful if you're running something, say, overnight and you're not going to be there and an error happens on your first or your second file and the other hundred files you're trying to copy don't go because this script just stops. So what you can do is you can put the /c, it'll hit an error, it'll do whatever it needs to, and then it'll jump to the next one, so it'll make its copies. The /q suppresses display of the xcopy messages. So it's kind of nice you don't have to sit there and worry about the output coming out and mucking up whatever you're, if you're saving any output or anything like that. And then also this, the /I. If you're sending it someplace, and you're just going to explicitly tell it, it may not be able to determine based on the attributes of that folder or the name that it's a actual folder or a directory, so you can force it, so to speak, and tell it, "This is a folder," and go ahead and copy it in there. Any questions? Oh, go ahead. Student: Why is it that Microsoft can never get copyright? Instructor: I... Student: Problem is, one of them was on error it always fails. Especially when you have a lot of files to do. Instructor: Yeah. Page 7 of 24 Student: Okay. So you ignore the errors. So then by now you are faced with two options, delete everything that you did here and just start the whole thing over again, or tell it to copy again. Well, suppose this time you turned on the ignore error, how would you know which ones caused the error that you can go and fix them later, and also how could you make the copy see that these already succeeded, don't copy them over again, just copy the ones that aren't there? Instructor: So in this case-- Student: So why don't we list for, switch for, copy, what's not there yet? Instructor: Okay. So this is not all- inclusive, by any means actually. Student: Oh, there's more? Page 8 of 24 xcopy Options -2 xcopy Options -2 [/u] – Copy only files that already exist in destination [/s] – Copy non-empty folders and sub-folders [/t] – Copy subdirectory structure only, not files [/e] – Copy folder and sub-folders, including empty [/r ] – Copy read-only files [/h] – Copy hidden and system files [/d[:mm-dd-yyyy] – Copy file changed on or after the specified date – default copies source date/time is newer then destination [/exclude:filename1[+[filename2]][+[filename3]] Specify a file containing a list of strings to exclude [/z] – Copy in restartable mode for network copies 6 **006 Instructor: We'll be moving on to some that, see, the u up there, /u, copy only files that already exist. So this is kind of a backup. That would be good for backups if you want to make backups of certain files that already exist in the destination folder. They'll go out and it'll go look for it. So you kind of want the reverse of that if you're looking for it, right? Student: Yeah. Instructor: So you can also expressly tell it to copy non-empty folders and subfolders only, so you don't sit there and go out and make Page 9 of 24 copies of directories that don't have anything in them. So if you'd like to make the subdirectory structure only, without files, so if you have a, I don't know, a baseline computer that you'd like to have all the, a specific, like, per person, per basic user, if you want to have a temp file and then a share file and then a whatever that structure is, but you don't need to copy every, all the files that you have in yours, or whatever computer you're copying them from. You can use the /t, and it'll copy just the file, the folder structure, if you will, the directory structure in that way, not the files themselves, so..
Recommended publications
  • Copy — Copy file from Disk Or URL
    Title stata.com copy — Copy file from disk or URL Syntax Description Options Remarks and examples Also see Syntax copy filename1 filename2 , options filename1 may be a filename or a URL. filename2 may be the name of a file or a directory. If filename2 is a directory name, filename1 will be copied to that directory. filename2 may not be a URL. Note: Double quotes may be used to enclose the filenames, and the quotes must be used if the filename contains embedded blanks. options Description public make filename2 readable by all text interpret filename1 as text file and translate to native text format replace may overwrite filename2 replace does not appear in the dialog box. Description copy copies filename1 to filename2. Options public specifies that filename2 be readable by everyone; otherwise, the file will be created according to the default permissions of your operating system. text specifies that filename1 be interpreted as a text file and be translated to the native form of text files on your computer. Computers differ on how end-of-line is recorded: Unix systems record one line-feed character, Windows computers record a carriage-return/line-feed combination, and Mac computers record just a carriage return. text specifies that filename1 be examined to determine how it has end-of-line recorded and that the line-end characters be switched to whatever is appropriate for your computer when the copy is made. There is no reason to specify text when copying a file already on your computer to a different location because the file would already be in your computer’s format.
    [Show full text]
  • Windows Command Prompt Cheatsheet
    Windows Command Prompt Cheatsheet - Command line interface (as opposed to a GUI - graphical user interface) - Used to execute programs - Commands are small programs that do something useful - There are many commands already included with Windows, but we will use a few. - A filepath is where you are in the filesystem • C: is the C drive • C:\user\Documents is the Documents folder • C:\user\Documents\hello.c is a file in the Documents folder Command What it Does Usage dir Displays a list of a folder’s files dir (shows current folder) and subfolders dir myfolder cd Displays the name of the current cd filepath chdir directory or changes the current chdir filepath folder. cd .. (goes one directory up) md Creates a folder (directory) md folder-name mkdir mkdir folder-name rm Deletes a folder (directory) rm folder-name rmdir rmdir folder-name rm /s folder-name rmdir /s folder-name Note: if the folder isn’t empty, you must add the /s. copy Copies a file from one location to copy filepath-from filepath-to another move Moves file from one folder to move folder1\file.txt folder2\ another ren Changes the name of a file ren file1 file2 rename del Deletes one or more files del filename exit Exits batch script or current exit command control echo Used to display a message or to echo message turn off/on messages in batch scripts type Displays contents of a text file type myfile.txt fc Compares two files and displays fc file1 file2 the difference between them cls Clears the screen cls help Provides more details about help (lists all commands) DOS/Command Prompt help command commands Source: https://technet.microsoft.com/en-us/library/cc754340.aspx.
    [Show full text]
  • Mac Keyboard Shortcuts Cut, Copy, Paste, and Other Common Shortcuts
    Mac keyboard shortcuts By pressing a combination of keys, you can do things that normally need a mouse, trackpad, or other input device. To use a keyboard shortcut, hold down one or more modifier keys while pressing the last key of the shortcut. For example, to use the shortcut Command-C (copy), hold down Command, press C, then release both keys. Mac menus and keyboards often use symbols for certain keys, including the modifier keys: Command ⌘ Option ⌥ Caps Lock ⇪ Shift ⇧ Control ⌃ Fn If you're using a keyboard made for Windows PCs, use the Alt key instead of Option, and the Windows logo key instead of Command. Some Mac keyboards and shortcuts use special keys in the top row, which include icons for volume, display brightness, and other functions. Press the icon key to perform that function, or combine it with the Fn key to use it as an F1, F2, F3, or other standard function key. To learn more shortcuts, check the menus of the app you're using. Every app can have its own shortcuts, and shortcuts that work in one app may not work in another. Cut, copy, paste, and other common shortcuts Shortcut Description Command-X Cut: Remove the selected item and copy it to the Clipboard. Command-C Copy the selected item to the Clipboard. This also works for files in the Finder. Command-V Paste the contents of the Clipboard into the current document or app. This also works for files in the Finder. Command-Z Undo the previous command. You can then press Command-Shift-Z to Redo, reversing the undo command.
    [Show full text]
  • This Document Explains How to Copy Ondemand5 Data to Your Hard Drive
    Copying Your Repair DVD Data To Your Hard Drive Introduction This document explains how to copy OnDemand5 Repair data to your hard drive, and how to configure your OnDemand software appropriately. The document is intended for your network professional as a practical guide for implementing Mitchell1’s quarterly updates. The document provides two methods; one using the Xcopy command in a DOS window, and the other using standard Windows Copy and Paste functionality. Preparing your System You will need 8 Gigabytes of free space per DVD to be copied onto a hard drive. Be sure you have the necessary space before beginning this procedure. Turn off screen savers, power down options or any other program that may interfere with this process. IMPORTANT NOTICE – USE AT YOUR OWN RISK: This information is provided as a courtesy to assist those who desire to copy their DVD disks to their hard drive. Minimal technical assistance is available for this procedure. It is not recommended due to the high probability of failure due to DVD drive/disk read problems, over heating, hard drive write errors and memory overrun issues. This procedure is very detailed and should only be performed by users who are very familiar with Windows and/or DOS commands. Novice computers users should not attempt this procedure. Copying Repair data from a DVD is a time-consuming process. Depending on the speed of your processor and/or network, could easily require two or more hours per disk. For this reason, we recommend that you perform the actual copying of data during non-business evening or weekend hours.
    [Show full text]
  • “Log” File in Stata
    Updated July 2018 Creating a “Log” File in Stata This set of notes describes how to create a log file within the computer program Stata. It assumes that you have set Stata up on your computer (see the “Getting Started with Stata” handout), and that you have read in the set of data that you want to analyze (see the “Reading in Stata Format (.dta) Data Files” handout). A log file records all your Stata commands and output in a given session, with the exception of graphs. It is usually wise to retain a copy of the work that you’ve done on a given project, to refer to while you are writing up your findings, or later on when you are revising a paper. A log file is a separate file that has either a “.log” or “.smcl” extension. Saving the log as a .smcl file (“Stata Markup and Control Language file”) keeps the formatting from the Results window. It is recommended to save the log as a .log file. Although saving it as a .log file removes the formatting and saves the output in plain text format, it can be opened in most text editing programs. A .smcl file can only be opened in Stata. To create a log file: You may create a log file by typing log using ”filepath & filename” in the Stata Command box. On a PC: If one wanted to save a log file (.log) for a set of analyses on hard disk C:, in the folder “LOGS”, one would type log using "C:\LOGS\analysis_log.log" On a Mac: If one wanted to save a log file (.log) for a set of analyses in user1’s folder on the hard drive, in the folder “logs”, one would type log using "/Users/user1/logs/analysis_log.log" If you would like to replace an existing log file with a newer version add “replace” after the file name (Note: PC file path) log using "C:\LOGS\analysis_log.log", replace Alternately, you can use the menu: click on File, then on Log, then on Begin.
    [Show full text]
  • Basic STATA Commands
    Summer School on Capability and Multidimensional Poverty OPHI-HDCA, 2011 Oxford Poverty and Human Development Initiative (OPHI) http://ophi.qeh.ox.ac.uk Oxford Dept of International Development, Queen Elizabeth House, University of Oxford Basic STATA commands Typical STATA window Review Results Variables Commands Exploring your data Create a do file doedit Change your directory cd “c:\your directory” Open your database use database, clear Import from Excel (csv file) insheet using "filename.csv" Condition (after the following commands) if var1==3 or if var1==”male” Equivalence symbols: == equal; ~= not equal; != not equal; > greater than; >= greater than or equal; < less than; <= less than or equal; & and; | or. Weight [iw=weight] or [aw=weight] Browse your database browse Look for a variables lookfor “any word/topic” Summarize a variable (mean, standard su variable1 variable2 variable3 deviation, min. and max.) Tabulate a variable (per category) tab variable1 (add a second variables for cross tabs) Statistics for variables by subgroups tabstat variable1 variable2, s(n mean) by(group) Information of a variable (coding) codebook variable1, tab(99) Keep certain variables (use drop for the keep var1 var2 var3 opposite) Save a dataset save filename, [replace] Summer School on Capability and Multidimensional Poverty OPHI-HDCA, 2011 Creating Variables Generate a new variable (a number or a gen new_variable = 1 combinations of other variables) gen new_variable = variable1+ variable2 Generate a new variable conditional gen new_variable
    [Show full text]
  • Powerview Command Reference
    PowerView Command Reference TRACE32 Online Help TRACE32 Directory TRACE32 Index TRACE32 Documents ...................................................................................................................... PowerView User Interface ............................................................................................................ PowerView Command Reference .............................................................................................1 History ...................................................................................................................................... 12 ABORT ...................................................................................................................................... 13 ABORT Abort driver program 13 AREA ........................................................................................................................................ 14 AREA Message windows 14 AREA.CLEAR Clear area 15 AREA.CLOSE Close output file 15 AREA.Create Create or modify message area 16 AREA.Delete Delete message area 17 AREA.List Display a detailed list off all message areas 18 AREA.OPEN Open output file 20 AREA.PIPE Redirect area to stdout 21 AREA.RESet Reset areas 21 AREA.SAVE Save AREA window contents to file 21 AREA.Select Select area 22 AREA.STDERR Redirect area to stderr 23 AREA.STDOUT Redirect area to stdout 23 AREA.view Display message area in AREA window 24 AutoSTOre ..............................................................................................................................
    [Show full text]
  • 1. Xcopy 2. No, You Cannot Use the Xcopy Command in Your Assignment
    Intro to Operating Systems CNET 173 Assignment #4 Windows / LINUX Command Line Commands You are to list twenty-five command line commands of each operating system (WINDOWS and LINUX). That’s twenty- five WINDOWS commands and twenty-five LINUX commands. For each command you are to give: 1. The command a. Description/Attribute of the command b. Syntax of the command and c. A maximum of five Parameters used with the command and a description of the parameter. (If there are less than five parameters, list all parameters associated with the command.) Each command should be numbered and grouped (all WINDOWS commands with WINDOWS commands). Command information should be listed in the 1, a, b, c order listed above (i.e. command, description, syntax and parameters). This assignment must be typed and submitted through CANVAS. It should include a title page consisting of your name, course name, number, day and time, assignment name, instructor’s name, and due date and the assignment instructions. Example listed below. Windows Command Line Commands 1. xcopy a) Description - Copies files and directories, including subdirectories. b) Syntax xcopy Source [Destination] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d[:mm-dd-yyyy]] [/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a|/m}] [/n] [/o] [/x] [/exclude:file1[+[file2]][+[file3]] [{/y|/-y}] [/z] c) Parameters /w : Displays the following message and waits for your response before starting to copy files: Press any key to begin copying file(s) /p : Prompts you to confirm whether you want to create each destination file. /c : Ignores errors. /v : Verifies each file as it is written to the destination file to make sure that the destination files are identical to the source files.
    [Show full text]
  • How to Cheat at Windows System Administration Using Command Line Scripts
    www.dbebooks.com - Free Books & magazines 405_Script_FM.qxd 9/5/06 11:37 AM Page i How to Cheat at Windows System Administration Using Command Line Scripts Pawan K. Bhardwaj 405_Script_FM.qxd 9/5/06 11:37 AM Page ii Syngress Publishing, Inc., the author(s), and any person or firm involved in the writing, editing, or produc- tion (collectively “Makers”) of this book (“the Work”) do not guarantee or warrant the results to be obtained from the Work. There is no guarantee of any kind, expressed or implied, regarding the Work or its contents.The Work is sold AS IS and WITHOUT WARRANTY.You may have other legal rights, which vary from state to state. In no event will Makers be liable to you for damages, including any loss of profits, lost savings, or other incidental or consequential damages arising out from the Work or its contents. Because some states do not allow the exclusion or limitation of liability for consequential or incidental damages, the above limitation may not apply to you. You should always use reasonable care, including backup and other appropriate precautions, when working with computers, networks, data, and files. Syngress Media®, Syngress®,“Career Advancement Through Skill Enhancement®,”“Ask the Author UPDATE®,” and “Hack Proofing®,” are registered trademarks of Syngress Publishing, Inc.“Syngress:The Definition of a Serious Security Library”™,“Mission Critical™,” and “The Only Way to Stop a Hacker is to Think Like One™” are trademarks of Syngress Publishing, Inc. Brands and product names mentioned in this book are trademarks or service marks of their respective companies.
    [Show full text]
  • PC23 and PC43 Desktop Printer User Manual Document Change Record This Page Records Changes to This Document
    PC23 | PC43 Desktop Printer PC23d, PC43d, PC43t User Manual Intermec by Honeywell 6001 36th Ave.W. Everett, WA 98203 U.S.A. www.intermec.com The information contained herein is provided solely for the purpose of allowing customers to operate and service Intermec-manufactured equipment and is not to be released, reproduced, or used for any other purpose without written permission of Intermec by Honeywell. Information and specifications contained in this document are subject to change without prior notice and do not represent a commitment on the part of Intermec by Honeywell. © 2012–2014 Intermec by Honeywell. All rights reserved. The word Intermec, the Intermec logo, Fingerprint, Ready-to-Work, and SmartSystems are either trademarks or registered trademarks of Intermec by Honeywell. For patent information, please refer to www.hsmpats.com Wi-Fi is a registered certification mark of the Wi-Fi Alliance. Microsoft, Windows, and the Windows logo are registered trademarks of Microsoft Corporation in the United States and/or other countries. Bluetooth is a trademark of Bluetooth SIG, Inc., U.S.A. The products described herein comply with the requirements of the ENERGY STAR. As an ENERGY STAR partner, Intermec Technologies has determined that this product meets the ENERGY STAR guidelines for energy efficiency. For more information on the ENERGY STAR program, see www.energystar.gov. The ENERGY STAR does not represent EPA endorsement of any product or service. ii PC23 and PC43 Desktop Printer User Manual Document Change Record This page records changes to this document. The document was originally released as Revision 001. Version Number Date Description of Change 005 12/2014 Revised to support MR7 firmware release.
    [Show full text]
  • KEYBOARD SHORTCUTS (Windows)
    KEYBOARD SHORTCUTS (Windows) Note: For Mac users, please substitute the Command key for the Ctrl key. This substitution with work for the majority of commands _______________________________________________________________________ General Commands Navigation Windows key + D Desktop to foreground Context menu Right click Alt + underlined letter Menu drop down, Action selection Alt + Tab Toggle between open applications Alt, F + X or Alt + F4 Exit application Alt, Spacebar + X Maximize window Alt, Spacebar + N Minimize window Ctrl + W Closes window F2 Renames a selected file or folder Open Programs To open programs from START menu: Create a program shortcut and drop it into START menu To open programs/files on Desktop: Select first letter, and then press Enter to open Dialog Boxes Enter Selects highlighted button Tab Selects next button Arrow keys Selects next (>) or previous button (<) Shift + Tab Selects previous button _______________________________________________________________________ Microsoft Word Formatting Ctrl + P Print Ctrl + S Save Ctrl + Z Undo Ctrl + Y Redo CTRL+B Make text bold CTRL+I Italicize CTRL+U Underline Ctrl + C Copy Ctrl + V Paste Ctrl + X Copy + delete Shift + F3 Change case of letters Ctrl+Shift+> Increase font size Ctrl+Shift+< Decrease font size Highlight Text Shift + Arrow Keys Selects one letter at a time Shift + Ctrl + Arrow keys Selects one word at a time Shift + End or Home Selects lines of text Change or resize the font CTRL+SHIFT+ > Increase the font size 1 KEYBOARD SHORTCUTS (Windows) CTRL+SHIFT+ <
    [Show full text]
  • 11 Creating New Variables Generate and Replace This Chapter Shows the Basics of Creating and Modifying Variables in Stata
    11 Creating new variables generate and replace This chapter shows the basics of creating and modifying variables in Stata. We saw how to work with the Data Editor in [GSM] 6 Using the Data Editor—this chapter shows how we would do this from the Command window. The two primary commands used for this are • generate for creating new variables. It has a minimum abbreviation of g. • replace for replacing the values of an existing variable. It may not be abbreviated because it alters existing data and hence can be considered dangerous. The most basic form for creating new variables is generate newvar = exp, where exp is any kind of expression. Of course, both generate and replace can be used with if and in qualifiers. An expression is a formula made up of constants, existing variables, operators, and functions. Some examples of expressions (using variables from the auto dataset) would be 2 + price, weight^2 or sqrt(gear ratio). The operators defined in Stata are given in the table below: Relational Arithmetic Logical (numeric and string) + addition ! not > greater than - subtraction | or < less than * multiplication & and >= > or equal / division <= < or equal ^ power == equal != not equal + string concatenation Stata has many mathematical, statistical, string, date, time-series, and programming functions. See help functions for the basics, and see[ D] functions for a complete list and full details of all the built-in functions. You can use menus and dialogs to create new variables and modify existing variables by selecting menu items from the Data > Create or change data menu. This feature can be handy for finding functions quickly.
    [Show full text]