Lesson 9B: Command Prompt Part 2 – Paths, Wildcards & Lab Operations
Chapter 9 & 9B study guide: File copy & move operations, Absolute vs Relative addressing, wildcard pattern matching (* and ?), and complete Lab 10 walkthrough.
1. Quick notes
Annotate and print
Use the tool bar at the bottom of the screen to highlight text, draw, and add sticky notes or text on top of these notes. Then save a PDF with or without your marks.
In the print window, choose "Save as PDF" as the destination. Chrome or Edge gives the best result.
Copy & Move Command Syntax
- COPY: Duplicates a file from source to destination without deleting the original.
copy [source_path\file] [destination_path]
Example:copy c:\inft1201\labs\labs.txt c:\inft1201\class - MOVE: Transfers a file to a new location, deleting it from the source.
move [source_path\file] [destination_path]
Example:move c:\inft1201\class\1101\sheet.xlsx c:\inft1201\labs\hardware\lab2 - Duplicate in Place:
copy toy.gif toy2.gif(creates a copy with a new name in the same folder). - Copy with Rename:
copy toy.gif c:\labs\newtoy.gif
Absolute vs Relative Addressing
- Absolute Address (Full Path): The complete file location starting from the drive letter root (e.g.
C:\inft1201\class\woody.jpg).
• Works identically regardless of your current working directory.
• Like your complete postal address (Country, City, District, Street, House #). - Relative Address: Specifies a path in relation to your current working directory.
• Uses..to navigate upward to parent folders.
• Like giving directions inside a mall ("go up one floor, turn right").
• Why essential in IT? Batch scripts running across multiple user computers (e.g. Reem vs Hassan) must use relative or variable paths because hardcoded usernames fail.
Evaluating Relative Paths (Tree Traversal)
Consider the course lab directory tree: C:\inft1201 containing branches labs\hardware\lab1, lab2 and class\2104, 1101.
| Current Directory | Target Item | Relative Path | Sample Command |
|---|---|---|---|
C:\inft1201\Labs> |
list.txt inside Lab1 |
Hardware\Lab1\list.txt |
type Hardware\Lab1\list.txt |
C:\inft1201\Labs> |
toy.gif in parent folder |
..\toy.gif |
copy ..\toy.gif . |
C:\inft1201\Labs> |
1101 folder in Class branch |
..\class\1101 |
cd ..\class\1101 |
C:\inft1201\Labs> |
Create file homework.txt in 1101 |
..\class\1101\homework.txt |
copy con ..\class\1101\homework.txt |
C:\inft1201\Labs\hardware> |
1101 folder in Class branch |
..\..\class\1101 |
cd ..\..\class\1101 |
C:\inft1201\Labs\hardware> |
Create folder BB in 2104 |
..\..\class\2104\BB |
md ..\..\class\2104\BB |
Wildcards: The Asterisk (*)
Matches zero, one, or any number of arbitrary characters:
dir lab*: Matches all files starting withlab(e.g.Lab001,Lab003,laboratory list.pdf). Does not matchmath lab.dir *lab*: Matches files containinglabanywhere in the filename (e.g.available,Lab001,math lab,The Network Lab.txt).dir *lab: Matches files ending withlab(e.g.math lab; does not matchThe Network Lab.txtbecause it ends in.txt).dir *.xlsx: Displays all Microsoft Excel spreadsheets regardless of filename.dir *.*: Matches every single file with any filename and any extension.
Wildcards: The Question Mark (?)
Matches exactly one single character (or none in legacy 8.3):
dir sam?: Matches files starting withsamfollowed by at most 1 character (e.g.Sam,Sam1,Sam8). Does NOT matchSam16(has 2 characters after 'sam').dir ????: Matches files whose total name is 4 characters or fewer (e.g.a0,a006,a00b,lulu,tall).dir ?a*: Matches files where the second character isa(or first character if single-letter), followed by any characters.
Batch Operations with Wildcards
Wildcards empower IT technicians to process dozens of files in a single line:
- Copy all files containing "lab":
copy c:\wildcards\*lab* c:\inft1201\class - Copy all files starting with "a00":
copy c:\wildcards\a00* c:\inft1201\labs\hardware - Copy all files of any kind:
copy c:\wildcards\*.* c:\inft1201\class\1101 - Delete all temporary text files:
del c:\temp\*.tmp
Lab 10 / Session 2 Practical Walkthrough Solutions
Official command solutions for the Lab 10 hands-on tasks:
| Step # | Task Description | Exact CMD Command | Verification |
|---|---|---|---|
| S5 | Copy toy.gif to labs folder |
copy c:\inft1201\toy.gif c:\inft1201\labs |
tree /f inft1201 shows toy.gif in root & labs. |
| S6 | Copy list.txt to 2104 folder |
copy c:\inft1201\labs\hardware\lab1\list.txt c:\inft1201\class\2104 |
list.txt appears in 2104. |
| S7 | Move sheet.xlsx to Lab2 folder |
move c:\inft1201\class\1101\sheet.xlsx c:\inft1201\labs\hardware\lab2 |
sheet.xlsx removed from 1101, placed in Lab2. |
| S8 | Move network.docx to 1101 folder |
move c:\inft1201\labs\hardware\lab1\network.docx c:\inft1201\class\1101 |
network.docx moved into 1101. |
| S9 | Copy labs.txt to Lab1 folder |
copy c:\inft1201\labs\labs.txt c:\inft1201\labs\hardware\lab1 |
labs.txt duplicated into Lab1. |
| S10 | Move report.pdf to class folder |
move c:\inft1201\class\2104\report.pdf c:\inft1201\class |
report.pdf moved one level up to class. |
| S11 | Copy woody.jpg to Hardware folder |
copy c:\inft1201\class\woody.jpg c:\inft1201\labs\hardware |
woody.jpg duplicated into hardware. |
2. Multiple-choice check
Test your knowledge of Chapter 9 & 9B concepts. Score at least 80% to earn your completion certificate.
3. Short written answers
Click on any question to reveal the recommended exam answer key.