When my wife and I first got married, she took care of our monthly bills. Each month bills would pile into the desk and once a month or so, she would go up to the office and pay the bills. Then after paying the bills, she would sort and file them in a cabinet for reference. Most of the time, we never look at the bills in the cabinet, but occasionally, we review a previous bill to compare it against the current one. Sometimes for trending an electric bill, most often to see where the rate increased.
Eventually it was decided that it was my turn to handle the bills (something about pulling my weight around the house). We both soon discovered that I am horrible at organizing and filing away the bills into folders. After much deliberation, we decided that I would scan the bills and place them in folders on the computer. In order to best organize them, they were placed in a “Bills/2013/<person we owe money to>” structure. The problem I have run into is that at the beginning of the year, I end up creating a folder for the new year, then manually creating 20 plus new folders with the correct names. I would just copy the whole directory, but then it would include all of the PDF files of the bills in that folder.
Being a lazy guy, I endure this task saying that I should automate the task but never bother. This year, my father was mentioning to me that he has the same problem with is personal and professional folders. I figured that with a need greater than just mine, I would create a program that copies just the folders. I look for every opportunity to “pay back” my parents for all of the opportunities they have provided me with my life.
I spent about an hour writing a simple program that would copy the folders without the files (including sub directories). It wasn’t hard and I didn’t have to look anything up as it was a simple program. I actually had more problem trying to email the file dad as his email provider didn’t like .exe or .zip files…
I sent the program to dad and he was quite happy to have it. He sent it to other people in his office that had the same problem. Simple code that was a hit in a local accounting office.
The story would have ended there, but I was doing some work on my company’s software Continuous Integration build server. I had to copy some files over the network. I was looking into the properties for “xcopy” and came across the following documentation.
xcopy /t /e “C:\Your Folder” “C:\New Folder”
/t = Copies the subdirectory structure, but not the files
/e = Copies subdirectories, including empty ones
This got me thinking, and I did a Google search (https://www.google.com/search?q=Copy+folders+without+files). According to Google results, about 17 million results were returned with people looking for or solving this relatively simple problem. Some result pages offered multiple solutions from the built in Windows commands to elaborate custom projects that make my simple copy program seem insignificant.
The point I realized is that being a software engineer, I should have been smarter. It is very easy for me to write a quick program to solve a problem, but maybe I should be looking for alternate existing solutions before I dig in and just start writing code. Maybe I wouldn’t have missed that big play during the game if I wasn’t on the sofa writing the solution to a problem that has already been solved many times! How many other places in my professional career should I be looking for existing solutions instead of making my own?