Learn Understand first, then practice while the concept is still fresh.

M09 - File Operations: Copy, Move, Delete

Copy, move, rename, delete, and archive files safely so you can reorganize work without losing track of what changed.

File System

File Operations: Copy, Move, Delete

Copy, move, rename, delete, and archive files safely so you can reorganize work without losing track of what changed.

45 min INTERMEDIATE BOTH Field-verified
What you should be able to do after this
  • Copy files and folders to a new location.
  • Move or rename items intentionally.
  • Delete only after checking the target.
  • Package a folder into one archive for transfer or backup.

Why This Matters

These commands are simple, but they change the file system for real.

That is why this lesson is about judgment as much as syntax:

  • copy before you risk a change
  • confirm the path before you move
  • delete only when you are sure

If you build those habits now, the commands stay useful instead of becoming dangerous.


1. Copy First

Copying is the safest way to preserve the original while you reorganize or experiment.

Copy Files and Folders

Copy one file

Copy-Item .\report.txt .\backup\report.txt

Copy one folder and everything inside it

Copy-Item .\Project .\Project-copy -Recurse

Copy Files and Folders

Copy one file

cp ./report.txt ./backup/report.txt

Copy one folder and everything inside it

cp -r ./Project ./Project-copy

If the result matters, list the destination afterward and verify it.


2. Move or Rename

Moving changes where something lives. Renaming changes its label. On the command line, those are often the same command.

Move or Rename

Rename in the same folder

Move-Item .\draft.txt .\notes.txt

Move into another folder

Move-Item .\notes.txt .\archive\

Move or Rename

Rename in the same folder

mv ./draft.txt ./notes.txt

Move into another folder

mv ./notes.txt ./archive/

When you are learning, move one item at a time first. Bulk moves can wait.


3. Delete With a Checklist

Deletion is not the place for speed.

Use this checklist before you press Enter:

  1. Am I in the directory I think I am?
  2. Did I list the target first?
  3. Am I deleting a practice file, not something important?
  4. If a wildcard is involved, do I understand exactly what it matches?
Delete Carefully

Delete one file

Remove-Item .\old-note.txt

Delete one folder and its contents

Remove-Item .\old-project -Recurse

Delete Carefully

Delete one file

rm ./old-note.txt

Delete one folder and its contents

rm -r ./old-project

Safer Beginner Rule

Do not start with force flags. Learn the plain command first, in a practice folder, and confirm the result after each step.


4. Archive for Transfer or Backup

Sometimes you need one file that represents a whole folder.

Create a Zip Archive

Compress-Archive -Path .\Project -DestinationPath .\Project.zip

Create a Tar Archive

tar -czvf Project.tar.gz ./Project

Archives help when you want to transfer, back up, or snapshot a directory.


A Reliable Practice Pattern

In a practice directory:

  1. Create a file.
  2. Copy it to a backup name.
  3. Rename the original.
  4. Remove only the backup copy.
  5. Archive the folder.

That sequence teaches more than memorizing flags.


What to Ignore for Now

  • hard links and symbolic links
  • destructive force flags by default
  • advanced archive options

Those topics matter later, but they are not required for safe first use.


Before You Move On

You are ready when you can explain, in your own words:

  1. why copying is safer than moving when you are unsure
  2. how renaming uses the same move command
  3. why deletion requires an explicit check step
  4. why archives are useful

Next, we focus on finding programs and files when you do not remember where they live.