This is my first post on this website so I thought I should make it a good one. I was working with my S3 bucket the other day from my Mac laptop and uploaded a few files without giving it any thought. Got home and jumped on my PC to download these files.. turns out I couldn’t download these files even though my permissions were correct to download them.
The error presented was “IOError: [Errno 22] invalid mode (‘wb’) or filename: ‘C:\\Users\\Dustin\Documents\Logs-12:22:13PM.txt'”
Naturally, I googled for why Errno 22 would be returned and it turns out the colon character is not allowed within a filename for a Windows machine, who would have thought?!
Even though I only had a few files with colons within the filename, I thought it might be helpful to create a Python script using the Boto3 SDK to remove the colons so that I could actually edit them on my PC.
Below I’ve added the file with the appropriate comments explaining what it does. I hope you get as much, if not more, use out of it as I have.