Making and Moving

Make folders and files, then copy, move and rename them, many at a time.

Updated

Making

  1. Making Folders and Files: mkdir and touch (Novice): mkdir makes folders, several at once or a whole path of them with -p, and touch makes an empty file, so one line sets up a tidy place for your files.

Moving

  1. Copy, Move and Rename: cp and mv (Novice): mv moves a file into another folder or gives it a new name, cp makes a copy and leaves the original where it was, cp -r copies a whole folder, and -i or -n stop either one from replacing a file by surprise.

Many at Once

  1. Wildcards: *, ? and [ ] (Apprentice): A wildcard pattern such as *.jpg stands for every name that fits it, and the shell swaps in those names before the command runs, so echo shows you the list first and one mv moves every photo at once.
  2. Brace Expansion: Twelve Folders in One Line (Apprentice): Braces turn one word into many before a command runs, from a list such as {beach,city} or a range such as {01..12}, so mkdir makes a folder for every month in one line and cp file{,.bak} makes a quick backup.

Exercise: Sort the Downloads Folder

  1. Exercise: Sort the Downloads Folder (Apprentice): Sort a messy Downloads folder of photos, songs, a lease, a resume and a year of receipts into folders with mkdir, mv and cp, wildcards and braces, without replacing a thing, and let a check script tell you what's done.