quick & dirty rename


Sorting out everything for the transition to hugo and the wordpress plugins had created multiple copies of images in all different sizes I only need the main size plus the 150x150 as a thumbnail

rather than rename by hand every filename from filename-150x150.jpg to filename-thumb.jpg i wrote the following quick and dirty python to do for it for me :)

#!/usr/bin python
import os
import pdb

path='/home/lee/Pictures'
files = os.listdir(path)

for filename in os.listdir("."):
    if filename.endswith("150x150.jpg"):
        newname=filename[:-11]+"thumb.jpg"
        print(newname)
        os.rename(filename, newname)

Then it was simply a case of moving them into the relevant folders eg

 - /static
   - img
     - colour
     - bandw
     - lifeanddeath
     - pastlife
python 

See also