Imagine you are in a library with a big desk where you work on books. The books represent files on your computer. Copying a file is like taking a photocopy of a book from the shelf and placing the copy on your desk while the original stays on the shelf. Moving a file is like taking a book off one shelf and placing it on a different shelf -- the book is no longer on the first shelf but now lives on the new one. Deleting a file is like removing a book from the shelf and throwing it into the recycling bin; it's no longer available on the shelf or your desk.
Copying, moving, and deleting files in Intro to Computing - Real World Applications
Start learning this pattern below
Jump into concepts and practice - no test required
| Computing Concept | Real-World Equivalent | Explanation |
|---|---|---|
| File | Book | A file is like a book that contains information you want to read or work on. |
| Copying a file | Photocopying a book | Making a duplicate book to work on without changing the original on the shelf. |
| Moving a file | Taking a book from one shelf to another | The book is physically relocated; it no longer exists on the original shelf. |
| Deleting a file | Throwing a book into the recycling bin | The book is removed from the shelf and desk, no longer accessible. |
| Storage location (folder/directory) | Bookshelf | Where books (files) are kept organized. |
You arrive at your library desk to work on a project. You find a book on the shelf that you want to use. Instead of taking the original book off the shelf, you photocopy it and place the copy on your desk. This way, the original stays safe on the shelf, and you can write notes on your copy.
Later, you decide to reorganize the library. You take a book from one shelf and move it to a different shelf where it fits better. The book is no longer on the old shelf but now lives on the new one.
Finally, you find some old books that are no longer needed. You take them off the shelf and throw them into the recycling bin. They are gone from the library and your desk.
- Photocopying a book takes time and physical effort, but copying a file on a computer is usually very fast and automatic.
- Moving a book physically changes its location, but moving a file can sometimes be just updating a pointer if it's on the same storage device.
- Deleting a book in real life is permanent, but deleted files often go to a recycle bin or trash folder first, allowing recovery.
- Bookshelves are physical and limited by space, while digital folders can be expanded easily.
In our library desk analogy, what would be equivalent to moving a file from one folder to another?
Practice
copy a file on your computer?Solution
Step 1: Understand copying
Copying means making a duplicate file without deleting the original.Step 2: Compare with other actions
Moving removes the original, deleting removes permanently, renaming changes the name only.Final Answer:
A new file is created in the new location, and the original file stays where it is. -> Option DQuick Check:
Copying duplicates file = A [OK]
- Confusing copying with moving
- Thinking deleting is copying
- Believing renaming moves the file
report.txt from the folder Documents to Archives in a command-line interface?Solution
Step 1: Identify the move command
The command to move files is usuallymove(Windows) ormv(Unix).Step 2: Check other commands
copyduplicates,deleteremoves,renamechanges name only.Final Answer:
move Documents/report.txt Archives/ -> Option AQuick Check:
Move command = move [OK]
- Using copy instead of move
- Using delete to move files
- Confusing rename with move
shutil module:import shutil
shutil.copy('data.txt', 'backup/data.txt')
shutil.move('data.txt', 'archive/data.txt')What will happen after running this code?
Solution
Step 1: Understand shutil.copy()
This creates a duplicate of 'data.txt' in 'backup' folder; original remains.Step 2: Understand shutil.move()
This moves the original 'data.txt' from current location to 'archive', removing it from original place.Final Answer:
A copy of 'data.txt' is made in 'backup', then the original is moved to 'archive'. -> Option CQuick Check:
Copy then move = C [OK]
- Thinking move duplicates file
- Assuming copy deletes original
- Believing both files are deleted
del myfolder\file.txtBut you get an error saying the file is not found. What is the most likely cause?
Solution
Step 1: Check file path and existence
If the file path is wrong or file missing, deletion fails with 'not found' error.Step 2: Understand del command
deldeletes files; it works if file exists and path is correct.Final Answer:
The file path is incorrect or the file does not exist. -> Option AQuick Check:
File not found = wrong path or missing file [OK]
- Assuming del cannot delete files
- Trying to copy before deleting unnecessarily
- Ignoring file path correctness
Downloads to Pictures, but keep a backup copy in Backup. Which sequence of actions correctly achieves this?Solution
Step 1: Copy files to Backup
Copying duplicates files to Backup folder, preserving originals in Downloads.Step 2: Move files to Pictures
Moving transfers files from Downloads to Pictures, removing them from Downloads.Final Answer:
Copy all files from Downloads to Backup, then move all files from Downloads to Pictures. -> Option BQuick Check:
Copy backup first, then move original = B [OK]
- Moving before copying loses original files
- Deleting files before backup
- Copying from wrong folders
