To receive all future articles in a monthly email and get your FREE How to Start a Digital Archive Workbook!

HOW TO CREATE A FILE SYSTEM IN POWERSHELL | A Quick Way to Set Up a New Folder Structure

 

 

A useful tool for helping you keep your digital projects organised is PowerShell. If you are new to PowerShell, this is an easy step-by-step guide to help you set up a system to keep on top of your files.

 

I am assuming you are already confident using the graphical user interface (GUI) - i.e. the one that looks like this:

 

 

If not, then you will want to use a guide more like this one.

 

The Commands Toolkit

 

Here are the commands that you are going to need. I'm sticking these right at the top of the guide so they're easy for you to find. I'll explain each one as we go along.

 

cd = change directory

 

ls = list the elements inside the directory

 

pwd      = print working directory

 

mkdir   = make directory / create a new folder

 

mv = move something to a different directory

 

RenameItem = um, rename the item.

 

Get-ChildItem = selects anything that is sitting inside that folder.

 

-recurse = tells PowerShell to include everything in that folder, (including anything inside any of the sub-folders). Note the hypen at the beginning!

 

-file = tells PowerShell that you are referring to files only (i.e. not folders)

 

| (pipeline) = joins two instructions together

 

-Destination = tells PowerShell that the next piece of text is the filepath that you want to move your item to.

 

Before you start

 

Take a moment to think about what you are trying to achieve. In true MP;LP style, ask yourself:

 

1. What material are you working on?

 

2. Is it important to you?

 

3. What is the outcome you want?

 

To show you the process, I will be working on a folder called "Personal Archive 2007-10". I made this folder when I got a new laptop in 2010 and transferred all my old data across to the new one. I bunged all my old stuff in this folder, and transferred it whenever I got a new laptop - without ever looking at it again!

 

I know that it is important to me because there are definitely photos in there that I love.

 

My aim is to re-structure that material so that I can integrate that old material into my current system. I want all my photos, for example, to be together.

 

Once you know your why, you are ready to start.

 

Step 1: Open PowerShell

 

PowerShell is a command line tool to help speed up tasks up for you.

 

If you are on a Windows computer, PowerShell will have come pre-installed. Search for it in the Start menu. As of August 2016, it is open source and cross-platform. So you can install it if your device uses a different operating system.

 

Step 2: Navigate to the right place

 

The text across the top of the blue window will tell you where you are.

 

The command that you will need to move around is "cd" (change directory).

 

Type "cd" and a space. The cd will turn yellow to show you that it is an instruction.

 

Type the file path for where your material is currently stored. For me, that was Documents\0_Ingest\"Personal Archive 2007-10".

 

Hit enter, and you will have moved to that location.

 

If any of your folder or file names include a space, you need to include quotation marks around that element. That is why people generally tell you to avoid spaces in file- and folder-names. Try underscores or hyphens instead.

 

If you can't remember the file path, you can navigate to it:

 

List the elements in your current location by typing "ls" and hitting enter.

 

Type "cd" + space, and type the name of whichever folder you can see in the list that will take you to your material. Repeat until you get to where you need to be.

 

Navigating in this way is pretty cumbersome. So you can see why you want your finished structure to be easy to remember and without too many levels.

 

If you get lost, and can't work out which folder you are in, type "pwd" and hit enter. It will show you the file path for your current location.

 

Nifty tip to go up a level!

 

Type  "cd" +  space as before. Then type two dots ".." and hit enter to go up one level. Or type "..\.." to go up two levels (and so on).

 

That saves you having to type out the full name of the folders above where you are.

 

Step 3: What do you want to keep?

 

Have a look around, and decide what is worth investing the effort in keeping permanently. Are you currently using something? Are you required to keep it for a set period of time? Have you discovered real "digital treasure" - work that you are proud of and want to keep forever?

 

Step 4: Create new folders

 

Type "mkdir" + space. Type the name of your new folder. Hit enter.

 

I like to start by making a "Delete" folder!

 

You can check it's worked by typing "ls" and enter.

 

When you're creating folders, remember to keep it simple. Design it for the lazy version of yourself!

 

Step 5: Move stuff into a different folder

 

I have had a look inside the folder called "Pictures for schoolwork". There is nothing in there that I want to keep - mostly photos downloaded from the internet. I am going to shift the whole folder into my new "Delete" folder.

 

Type "mv" + space.

 

Type the name of the folder you want to move, then a space.

 

Type the name of the folder where you want to send it to.

 

Enter.

 

You can also do this with individual files. You will need to include the file extension.

 

Step 6: Rename folders

 

It turns out that my folder called "Random Pictures" is a collection of doodles I created in Paint. Calling the folder "Random Pictures" does not capture what they are. It means that I have to open the folder to find out what is in there.

 

Type "Rename-Item" + space.

 

Type the name of the item you want to change + space.

 

Type the new name (taking the opportunity to get rid of spaces!)

 

Step 7: Flatten your file structure

 

Remember back in Step 2, when we found it was easier to navigate when the file-path was short and memorable?

 

Flattening the structure reduces the number of "clicks" it takes to find something. So take files that are in folders-within-folders, and move them up to a higher level.

 

To move a set of folders (and everything inside them) from your current location to a different location:

 

Type Get-ChildItem -recurse | mv + space -Destination + space

 

Type the destination filepath.

 

Hit enter.

 

To move all the files within a set of folders into one folder (to flatten the structure even more):

 

Type Get-ChildItem -recurse -file | mv -Destination + space

 

Type destination filepath.

 

Hit enter

 

This takes the files out of their current folders, leaving the folders empty.

 

Step 8: Decide if you're done

 

Have a look at what you've created. Is it simple and easy for lazy-you to use? Have a quick look through your "Delete" folder and see if you're ready to actually delete it (or not!)

 

I'm happy with how my structure is looking. It's great to have all my music in one place. All I'm going to do is shift "Doodles" across to my digital scrapbook. And incorporate my photos into my current photograph system.

 

That's it! Done.

 

Okay, be honest with me

 

Was this actually helpful? I am aiming it at people who haven't used PowerShell much before. If you were a beginner, was this guide clear and easy to understand? If you are an expert have I got it more-or-less correct, or do you have any tips?

 

Thank you so much for reading this guide. You are incredible for making it right down to the end. I hope this has been an approachable starting-point for using PowerShell.

 

If you found this helpful, I would love for you to join my email community. I will send you a monthly email with all my future articles, and you will get my FREE How to Start A Digital Archive Workbook.

 

There are tons of resources out there, if you want to go deeper. I loved Zed A. Shaw's Command Line Crash Course.

 

Good luck setting up your new filing system. As always, I'd love to hear how you get on. You can either tweet me @ArchiveRobin, or drop me an email at charlotte@archiverobin.com.

 

 

Please reload

Please reload