Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
? batch rename images sequentially.
-
complete noob here. curious if this is even possible before I slog through it.
I'd like to select multiple images and rename them sequentially. I found a watermark app but it doesn't have a tool to do sequential numbering but it will rename per filename possibly with a prompt to enter a "start from" number.
any help would be appreciated. thanks in advance.
-
You would like to select multiple images from the iOS camera roll, local file system, dropbox, etc.?
You would like to store the resulting images where?
-
If reading and writing to the local file system, then something like this should work...
import os # create four dummy files in_file_names = ['in_file_number_{}.txt'.format(i) for i in xrange(7, 11)] print(in_file_names) for file_name in in_file_names: if not os.path.isfile(file_name): with open(file_name, 'w') as out_file: out_file.write('This file was only created for a demo.\n\tYou can safely delete this file.') # The real app starts here... def rename_files(in_file_names, out_file_fmt = '', starting_number = 1): out_file_fmt = out_file_fmt or 'freshly_watermarked_file_{:0>3}.txt' for in_file_name in in_file_names: out_file_name = out_file_fmt.format(starting_number) assert not os.path.isfile(out_file_name), 'File already exists: ' + out_file_name os.rename(in_file_name, out_file_name) starting_number += 1 rename_files(in_file_names)
-
something simple would be awesome, just a camera roll multi-select and saving back to camera roll using the sequences. That would be better so it would be closer to my skill level for learning.
my wish was worded a little off i just noticed. the prompt for a start number would let you add images to a sequence.
thank you for the reply!
-
It's currently not possible to set the file name when saving an image to the camera roll.
-
Do images in the camera roll even have names? They do of course when you plug your device into a computer and access it via the Windows Explorer or iPhoto, but who knows if those names are real. Old-fashioned audio CDs also don't have any files or file names, yet most operating systems show the individual tracks as named/numbered files.
-
@dgelessus: Yes. Images of the iOS camera roll do have file names.
The output of:
import photos print(photos.pick_image(include_metadata=True))
Contains:
u'filename': u'IMG_0921.PNG'
If you cancel the image picker, the code above throws an exception which I believe is a bug!
-
well, that's a bummer.
good news for me, the dev of the watermark app (http://plumamazing.com/win/iwatermark-pro/) replied to my suggestion and worked it in for the next weeks update.
bad news for you guys, I might have wasted your time ;-)
ccc that is going in my reference library though! thank you for that.