Python Tutorial: Automate Parsing and Renaming of Multiple Files

Video Rating: / 5



:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :confused: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

Current comment:15   Among:Visitors  15   Bloggers  0

    • avatar Marcin Gil 1


      • avatar Alexa Bing 1

        @Corey Schafer
        Hi, Corey. I want to thank you for these videos. I just start learning in Python which is going to be the first language I will learn and your videos are helping me a ton.
        Actually, at work, I am in the need to erase temporary files from a specific folder and I am sure it would be better to automate these task.
        Could you make a video that explains how to delete files from a specific folder which are older than x days? Thanks.

        • avatar David Harvey 2

          These look suspiciously like homework. If they started with a before and after, they would fit perfectly into your courses

          • avatar Yunes Abb Elita 2

            Nice and clear straight to what is important. Gjob!

            • avatar Max Yupanqui conza 1

              Sorry when I try to execute the "format", it gives me the "valueerror: zero length field name in format"

              • avatar Julie Wint 1

                That was so clear and straight to the point. You got yourself a subscriber!

                • avatar Stavros Michalovits 2

                  Where can I find this wallpaper?

                  • avatar Ashok Gujjuri 1

                    Brilliant job

                    • avatar Omar AM 1

                      Corey, this is great nugget, please keep posting similar videos, it is great tool and it help me automate few tasks that otherwise would have taken me a lot of time as you intended.


                      • avatar eliaking 0

                        I feel like a real IT guy right at this moment.

                        • avatar Anthony Anonde 2

                          i just want to know how he was able to write in three line at the same time?

                          • avatar Fernando Goya 1

                            Man, your channel is REALLY GOOD!!!! You teach us really cool things. Please, keep going!

                            • avatar Tad Peters 1

                              '''well, no one else did it, so I did. here is a short little pyscript to create the files in this tutorial. Part pilfered from stackoverflow by ephemient'''

                              import os

                              #change path as described by Corey, or leave as is and move folder

                              listoffiles =[
                              'Earth – Our Solar System – #4.mp4',
                              'Jupiter – Our Solar System – #6.mp4',
                              'Mars – Our Solar System – #5.mp4',
                              'Mercury – Our Solar System – #2.mp4',
                              'Neptune – Our Solar System – #8.mp4',
                              'Pluto – Our Solar System – #10.mp4',
                              'Saturn – Our Solar System – #7.mp4',
                              'The Sun – Our Solar System – #1.mp4',
                              'Uranus – Our Solar System – #9.mp4',
                              'Venus – Our Solar System – #3.mp4']

                              for fname in listoffiles:
                              with open(fname, 'a'):

                              print ('Complete')

                              • avatar chandra mohan ganapathy subramanian 1

                                Can anyone please clarify – i could n't understand the last step. The file was renamed from f to new_name. when the program was run , how come the file got sorted in order which is 1 to 10. It would be great if someone clarifies.

                                • avatar joseph batish 0

                                  Thank u this is so useful