Organising Files

Sounds simple enough, right? I thought it was too until I had to put a couple of things I’ve learnt together for the program to work.

I was working on ‘Selective Copy’ in Chapter 9 of ‘Automate the Boring Stuff with Python’.

Write a program that walks through a folder tree and searches for files with a certain file extension (such as .pdf or .jpg). Copy these files from whatever location they are in to a new folder.

I decided to only work with .pdf and over-complicated it by using regex to search for files with .pdf extension when it was as simple as using filename.endswith(.pdf):

Screen Shot 2017-07-28 at 5.18.45 PM

I then kept getting errors:

Screen Shot 2017-07-28 at 5.14.57 PM

I was quite annoyed as it took me awhile before realising that I needed all the files to be in the same directory for the program to work; such a fundamental mistake. Then again, these silly mistakes are inevitable for beginners and I believe there will be more of such mistakes in months to come as part of the learning phase.

Keeping my head up!

One thought on “Organising Files

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s