The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: RE: Re: SatNav Recommendations??


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: iPad photos (OT)



Do you know if it is the filesystems creation date / time, or the meta
data
(EXIF) date of the image?

If the former then the following python script will work.  You need python
installed and for the creation times to work correctly you need the pywin32
extensions for the creation date to work on windows.   If the latter then
the solution is not so simple.

Sam

--- set_image_dates_by_name.py ---
#!/usr/bin/env python
import errno, os, re, shutil, sys, time

def set_date(path, newtime):
"""Set the modification, access, and creation time of path
to newtime.

`newtime` is seconds since epoch as returned by os.stat(...).st_ctime.
"""
try:
import win32file, win32con
except ImportError:
os.utime(path, (newtime, newtime))
else:
h = win32file.CreateFile(path, win32file.GENERIC_WRITE, 0, None,
win32con.OPEN_EXISTING, 0, None)
t = time.localtime(newtime)
win32file.SetFileTime(h, t, t, t)
h.close()
print "hardway"

def set_image_dates_by_name(srcdir, destdir, filter=r'^.*\.(jpgjpeg)$'):
try:
os.makedirs(destdir)
except OSError, e:
if e.errno != errno.EEXIST:
raise

exp = re.compile(filter, re.I)
rolling_date = None
for f in sorted(os.listdir(srcdir)):
if exp.match(f):
src, dest = os.path.join(srcdir, f), os.path.join(destdir, f)
if srcdir != destdir:
shutil.copy2(src, dest)
if rolling_date:
rolling_date = rolling_date + 60.0
else:
rolling_date = os.stat(src).st_ctime
set_date(dest, rolling_date)
print "Copied", src, '=>', dest


if __name__ == "__main__":
try:
srcdir, destdir = sys.argv[1:3]
if not os.path.isdir(srcdir):
raise ValueError("SRCDIR does not exist or is not a directory")
except (IndexError, ValueError):
sys.exit("""Usage: set_image_dates_by_name.py SRCDIR DESTDIR

e.g. python set_image_dates_by_name.py . sorted_for_ipad

Copy all .jpg and .jpeg images in SRCDIR to DESTDIR.  The images are copied
in
name order.  The first file copied keeps it's modified time and access
time,
each subsequent file will have it's modified and access/creation/access
times
set to be one minute after the previous file.

SRCDIR must exist, DESTDIR will be created if it does not already exist.

DESTDIR can be the same as SRCDIR, though this is not recommended as this
operation can not be reversed.
""")

set_image_dates_by_name(srcdir, destdir)



On 7 April 2011 08:23, Peter + Jane <pandj.munnoch@xxxxxxx> wrote:

>
>
> Help!!
> I have created photo albums to take with us to show various friends
> in Germany.
> On pc I renamed them 001.jpg etc so I knew the correct order.
> The house build / ha ones (yep, there's my excuse for posting!!) are
> a mix of different pictures taken at different times over the last 5
years.
> Transfer them to iPad and it sorts them by creation date.
> No other option.
> I want them in name order.
> The "problem" is much discussed on Apple forums.
> A couple of possible Apps exist but get rubbish ratings.
> I am happy to buy an App if someone recommends it.
> I really don't want to have to edit in false dates on pc to each
> photo to cheat the Apple system, as I don't have the time.
> Has any list member tackled and overcome this (crazy) iPad limitation?
> TIA
> Peter
>
>
>


[Non-text portions of this message have been removed]



------------------------------------

<*> Join the Automated Home Forums
http://www.automatedhome.co.uk/vbulletin/


UKHA_D Main Index | UKHA_D Thread Index | UKHA_D Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.