Python Forum
Getting Correct Creation Time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting Correct Creation Time
#11
(Aug-14-2020, 06:26 PM)bowlofred Wrote: Can you show the column header from explorer?

Man, I'm gonna expose my noob-ness here. What's a "column header"? I probably know what it is but have never heard the term before.

I'll be trying out your other suggestions later tonight, tho. Thanks for those.

Right now I'm trying to get thru some Python tutorials.
Gotta keep progressing!

- John
Reply
#12
The top of the explorer window that shows the title for the column with the times. Does it say "creation time" or something else? Explorer can show times that aren't related to the filesystem information. In your snippet, there's no header visible.

The reason I ask is that I think your python code is correct as far as it goes and is printing the actual "ctime" in the filesystem. That makes me think that explorer is printing some other timestamp. I don't know what that is, so I don't have a suggestion on how to access it via python.
Reply
#13
(Aug-14-2020, 08:04 PM)bowlofred Wrote: The top of the explorer window that shows the title for the column with the times. Does it say "creation time" or something else? Explorer can show times that aren't related to the filesystem information. In your snippet, there's no header visible.


I'll check that out.

(Aug-14-2020, 08:04 PM)bowlofred Wrote: The reason I ask is that I think your python code is correct as far as it goes and is printing the actual "ctime" in the filesystem. That makes me think that explorer is printing some other timestamp. I don't know what that is, so I don't have a suggestion on how to access it via python.

BREAKTHROUGH!!

I think a big problem was that the getctime was accessing files from the same directory the ".py" file was in. So I had to define the directory first on each file. The other difference was when I used getmtime instead of getctime it grabbed the correct date.

So here's the code I wrote up and it does in deed display the correct date:

import os.path, time
path = ("C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD")
print()
print("Combining a directory path, file names, and actual creation date\n")
for root, dirs, files, in os.walk(path):
    for f in files:
        joined = (os.path.join(root, f))                        # joining the directory path with the file name
        actual_date = (time.ctime(os.path.getmtime(joined)))    # extracting the actual creation date form the file
        print(joined, actual_date)                              # printing the combined info

Let me know what you think of this code.

Here's the result:

Output:
C:\Python\John_Utilities\venv\Scripts\python.exe "C:/Python/John_Utilities/Extracting (Path_Name_Actual-Creation-Date).py" Combining a directory path, file names, and actual creation date C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7001.JPG Sun May 27 17:20:45 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7002.JPG Sun May 27 17:20:47 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7003.JPG Sun May 27 17:20:50 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7004.JPG Sun May 27 17:20:50 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7005.JPG Sun May 27 17:20:58 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7006.JPG Sun May 27 17:21:03 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7007.JPG Sun May 27 17:23:45 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7008.JPG Sun May 27 17:24:08 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7009.JPG Tue May 29 20:34:52 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7010.JPG Tue May 29 23:08:21 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7011.JPG Tue May 29 23:08:28 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7012.JPG Tue May 29 23:08:35 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7013.JPG Fri Jun 1 15:35:59 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7014.MOV Sun Jun 3 15:15:30 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7015.JPG Sun Jun 3 23:17:20 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7016.JPG Mon Jun 4 11:33:23 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7017.JPG Mon Jun 4 11:41:28 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7018.JPG Mon Jun 4 11:41:39 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7019.JPG Mon Jun 4 11:41:43 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7020.JPG Tue Jun 5 13:57:32 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7021.JPG Wed Jun 6 14:31:20 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7022.JPG Wed Jun 6 18:39:22 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7023.JPG Wed Jun 6 19:43:58 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7024.JPG Wed Jun 6 20:05:46 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7025.JPG Wed Jun 6 20:05:48 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7026.JPG Wed Jun 6 20:05:56 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7027.JPG Wed Jun 6 21:50:56 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7028.JPG Thu Jun 7 20:32:12 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7029.JPG Thu Jun 7 20:32:15 2012 C:\PHOTOS\DEVICE DUMP\iPhone\956BBRUD\IMG_7030.JPG Sat Jun 9 11:50:48 2012
From here I gotta figure out how to extract the info and rename the files to be formatted something like:
"[year]-[month]-[day]-[DESCRIPTIVE NAME]_[number].[extension]"

I think I can manage that.

Thanks for your assistance, bowlofred!

- John
Reply
#14
Makes no sense to me. Now that you're using getmtime(), it should be grabbing the modification date, not the creation date. But if it's working, that's good.
Reply
#15
(Aug-14-2020, 10:21 PM)bowlofred Wrote: Makes no sense to me. Now that you're using getmtime(), it should be grabbing the modification date, not the creation date. But if it's working, that's good.


Agreed. Makes no sense to me either. Maybe there's something weird about older iPhone data. This method might not work on other files.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to acquire an imported file creation time thunderspeed 4 1,939 Sep-23-2021, 04:27 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020