Or, A Cunning Plan for Archiving.
The first thing to do is a quick brain-dump of things I want the script to do. From that I should be able to get a better idea about how I want it to work.
So in no particular order here is a list of all the elements I want in the script;
- It needs to be able to move folders to an archive folder and replace them with a symbolic link to the new location (making the move transparent to the Operating System).
- It should also be able to reverse the process.
- While the script should be able to work having been given a full path to the item to be archived, I’d like it to work with wild-cards too (so I can archive all items with “Quake” in the name).
- Given the above, I’ll need some kind of confirmation to ensure I don’t process too many things when the wild-card presented is quite broad (like “*”).
- If a large list of items to archive is presented, I want some more information on each of them so I can make an educated decision about what to archive. Size of each folder (so I can see which are the best candidates for archive) is the minimum I think.
- As the original folder will be deleted after it is copied to the archive (in order to create the replacement symbolic link) I’ll need some kind of check to make sure the copied folder matches the original before the original is deleted. A size comparison should be good here.
- The list of items to be archived should be presented in an nicely formatted list and the user should get the ability to toggle each item for processing.
- Ideally items to be returned from the archive should be presented in the same format.
- Use PS Objects for as much of the output as possible like a good Powershell doozer.
- Allow use of streaming parameters where possible.
- Have the source and archive folders set as defaults; so I can just run the command with a folder to archive without worrying where it’s going to look for the folder or place the archive. If necessary, I should be able to override the defaults though.
I think that covers most things. Now to start making the Powershell magic happen.