Dynamic creation date set

Would you like Bulk Rename Utility to offer new functionality? Post your comments here!

Dynamic creation date set

Postby Sayasam » Sun May 07, 2023 10:05 am

Man, do I love BRU !

Unfortunately, I am using a stupid iOS app to hide my *cough* sensitive pictures *cough* which doesn't sort through file name but through file creation date, and I highly suspect it's precise up to the second. This leads to unsorted albums. Not good.

While changing app is very much on the table, I have noticed that BRU lacks a way (other than Javascript, I suppose) to dynamically change the creation dates of a list of files.

For example, set the creation date of the first selected file to 01/01/2000 00:00:00, then next file one second more, and so on.

That would be a very cool addition to BRU.
Sayasam
 
Posts: 4
Joined: Sun May 07, 2023 9:57 am

Re: Dynamic creation date set

Postby therube » Mon May 08, 2023 4:19 pm

I'd think you should be able to get it.
(Though I'm not quite sure in what format you're wanting.)

Take a look at the help for, Auto Date (8), & also the custom date formats.

BRU can read (exif) Date Created (or otherwise).
Date, Custom: you can "hardcode" something like; 01/01/2000 00:00:

And then, 10:Numbering, Mode: Suffix, Start: 1, Pad: 2.

That would allow for 99 pictures on 1-1-2000 00:00:01 - 00:00:99.

(That's assuming you wanted the picture named like that. Obviously :99 is not a valid time.)


Renaming Options | Prevent Duplicates, can help if you run into collisions.
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Dynamic creation date set

Postby Sayasam » Mon May 08, 2023 7:18 pm

therube wrote:Date, Custom: you can "hardcode" something like; 01/01/2000 00:00:

And then, 10:Numbering, Mode: Suffix, Start: 1, Pad: 2.


I'm afraid you misunderstood me. I do not want to rename the files names, but their creation date, as in, the file timestamps (14).
Sayasam
 
Posts: 4
Joined: Sun May 07, 2023 9:57 am

Re: Dynamic creation date set

Postby Sayasam » Mon May 08, 2023 8:03 pm

I remembered that I knew Python, so I did a Python script to do just that.

Code: Select all
# Auto-date a series of files of a folder

import filedate # python -m pip install filedate
import os
from datetime import datetime
from datetime import timedelta

STARTINGDATE = datetime(2000,1,1,0,0,0,0)
DELTA = timedelta(0,1,0,0,0,0,0)

print("Autodating program. This will change the creation date of all files of the folder. Confirm with 'y':")
answer=input()

if answer != 'y':
    exit()

currentdatetime = STARTINGDATE

try:   
    filenames = os.listdir(os.getcwd())
    for filename in filenames:
        if os.path.isdir(filename):
            continue
        if(filename.endswith(".py")):
            continue
       
        print(filename)
        file = filedate.File(filename)

        currentdatetime += DELTA
        file.set(
            created=currentdatetime.isoformat(),
            modified=currentdatetime.isoformat(),
            accessed=currentdatetime.isoformat()
            )
    print("All files successfully set")
except:
    print("An error occured")

input()


And it works.
Sayasam
 
Posts: 4
Joined: Sun May 07, 2023 9:57 am

Re: Dynamic creation date set

Postby therube » Thu May 11, 2023 6:25 pm

(Heh.
I saw your response, I while I saw "Python", it didn't compute.
I suppose mainly because that "weird" thing (to me) that BRU can use is JavaScript.
And I'm not familiar with JavaScript.

But I looked at your code, & I thought to myself,
"that looks pretty straight forward" & maybe I ought to acquaint myself with JavaScript.

Only to come to realize that you posted a Python solution rather then JavaScript.
JavaScript <> Python ;-).)
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm


Return to Suggestions