DEV Community

Cover image for Automating file organization via PowerShell
Brian Dys Sahagun
Brian Dys Sahagun

Posted on

Automating file organization via PowerShell

My process in sharing and archiving event media (aka the numerous pictures and videos that I take in various formal and informal events) is to, first, download the file from the memory card and sort them out according to the date and type of event. This is a tedious task especially if a batch consists of several days of events, or worse, several weeks. You can imagine that I would copy the folder from the memory card to my personal computer and that folder would contain all the raw files of the pictures that I took — they are not organized in folders initially.

The next step would be to categorize them in folders according to the date of the event they were taken. For the folder names, I’m using the ISO representation of date format, for example the date 2 October 2023 would be 2023-10-02. In this way, it’s easy to sort the folders chronologically; and even without the day or month, sorting still makes sense. Of course, I have done this manually for a very long time, until I’ve thought of using a batch file in creating all the dates of the year. The batch file approach helped a lot because it setup the folders with dates for all of 2023. With this approach, I simply check the files’ dates and drag them to their respective folders that were created by the batch file.

I still felt that it could be better — my current process was tedious than it’s supposed to be. So I searched for a batch file program that will automatically distribute the files into folders that have their respective dates. Where I arrived in my shallow search is at PowerShell.

Check out the script and complete steps in my blog.

Top comments (0)