Overview
This lecture explains how to copy files and directories in Windows, using both the graphical interface and PowerShell commands, including the use of wildcards and command parameters.
Copying Files and Directories in Windows GUI
- To copy a file or folder, right-click it and select Copy, then Paste.
- Keyboard hotkeys for copying and pasting are Control + C and Control + V.
Copying Files Using PowerShell
- Use the cp command in PowerShell to copy files.
- Syntax: cp <source file> <destination path>.
- Example: cp mycoolfile.txt Desktop copies mycoolfile.txt to the Desktop.
Using Wildcards for Multiple Files
- A wildcard is a character that represents any pattern of text in filenames.
- The asterisk (*) wildcard selects any file(s) matching a pattern (e.g., *.jpg).
- Example: cp .jpg <destination> copies all .jpg files to the specified location.
Copying Directories and Their Contents
- Copying a directory without parameters only copies the empty folder.
- Use the -Recurse parameter with cp to copy the directory and all its contents.
- The -Verbose parameter displays details for each copied file.
- Syntax: cp <directory> <destination> -Recurse -Verbose.
Verifying Actions
- The -Verbose flag shows a line in the CLI for every file copied, assisting in verification.
- Copying with both -Recurse and -Verbose ensures all subdirectories and files are included.
Key Terms & Definitions
- Hotkey — a keyboard shortcut for executing commands quickly.
- Wildcard — a character (typically *) used to match multiple files based on a pattern.
- cp — PowerShell command for copying files or directories.
- -Recurse — command parameter that copies all contents within directories and subdirectories.
- -Verbose — command parameter that outputs detailed information about the copy process.*
Action Items / Next Steps
- Practice copying files and directories using cp, with and without wildcards and parameters.
- Experiment using -Recurse and -Verbose to observe their effects.
- Review use of wildcards for different file extensions.