pythoniptcinfo

How to remove tails from images when adding metadata with iptcinfo3 (python)?


I'm working with from iptcinfo3, IPTCInfo. When I save metadata to the image, code below...

info = IPTCInfo(image_file, force=True)

adding metadata...

...

after that I save... info.save()

and this is when new file is created that has ~. These files are not visible when I open folder, but if I go to terminal - and type ls, I can see these files, also these files are taking my space. I see this like this in my terminal;

image1.jpg
image1.jpg~
image2.jpg
image2.jpg~
image3.jpg
image3.jpg~
image4.jpg
image4.jpg~
image5.jpg
image5.jpg~
image6.jpg
image6.jpg~

How to delete files with ~, or change code that these are not created?

Thanks in advance!


Solution

  • You need to set the overwrite option in your save function.

    info.save(options='overwrite')
    

    If you want to delete the files that end with ~, run:

    rm *~