Sort Files in a Directory and Number Them
DAY 10 👾
I’m back 💙
Exam days are ahead of me & I don’t have a hard copy to read from & ebooks for Digital Signal Processing (DSP) suck, atleast those I have. So, today I clicked some pics in my phone & as per the naming convention of my phone they are long strings like IMG_20164144090.jpg & so on… Now I want to sort them all & number them so that final result is 1.jpg. I have 2 languages for automating this task BASH & PYTHON. I’ll go with PYTHON as this usecase is more suitable for it.
Here’s the final Python Script
Firstly, I’ll import all the modules I need, i.e, os module & shutil module
os module
os module to change directories, get files in the directory & to get current working directory
sh module
sh module to copy file from one directory to another directory
Following is the Code with Explanation above each line
|
|