3

I'm looking for a utility that batch/bulk modifies file datestamps (date-modified and/or date-created) to the second accuracy but does so in ascending incremental order, e.g.

File1 2012-04-18 10:21:01
File2 2012-04-18 10:21:02
File3 2012-04-18 10:21:03

I want to do this because I want to force Flickr to order uploaded photos in a certain sequence.

I would like this for Windows or Mac. I have Ubuntu as well so could consider that, as a secondary choice.

6
  • What OS are you using?
    – Paul
    Apr 19, 2012 at 0:57
  • @Paul - Windows or Mac, I stated this in the question title but I didn't say which version. I run 7, XP and MacOs. Also Ubuntu, but would prefer Windows or Mac. Apr 19, 2012 at 1:08
  • Ah yeah, didn't see it in the title, I have added the tags
    – Paul
    Apr 19, 2012 at 1:13
  • 1
    You want to change them to be incremental, but on what criteria? The name?
    – Paul
    Apr 19, 2012 at 1:15
  • Are you sure that Flickr doesn't use the EXIF data in the images themselves? Apr 20, 2012 at 6:22

3 Answers 3

4

This

  • works in Linux/Mac,
  • uses no artificial delays to create time spread, and
  • keeps the modification date close to the original (I often find these dates handy in other contexts).

 

#!/bin/sh
REF=${1}
i=1
while [ $# -gt 1 ]; do
    if ! [ "${2}" = "${REF}" ]; then
        touch -h -r "${REF}" -d "+${i} seconds" "${2}"
        i=$((i+1))
    fi
    shift
done

Just specify the files in wanted temporal order and it will use the timestamp of the first file as a base, and add one second incrementally to each of the following arguments.

If the reference file is given multiple times, it will retain it's original time (this is only to be able to do e.g. "retime 0001.jpg *" without changing the reference timestamp). If another file is given multiple times, it will get the last logical timestamp.

Without -h, touch will dereference symbolic links, which is most probably not wanted in this case (if you say "symbolic what-now?", then don't worry).

3
  • Accepted @Daniel Anderson with thanks. The -h option is not available on CentOS Linux it seems - I get an error so I removed it. I know what symbolic links are but I wouldn't expect to be applying this script to those, it would be a defined list of images. Apr 23, 2012 at 9:28
  • retime 3.jpg 2.jpg 1.jpg this gives time order 1.jpg,2.jpg,3.jpg
    – zzapper
    Sep 18, 2013 at 17:27
  • @zzapper: Are you sure? I just tested it, and it works as described in the post here (and I can't see how the reverse ordering would happen from the logic in the script). Sep 18, 2013 at 20:15
3

Good Question although maybe Flickr should have any option for ordering the uploaded files.

For Windows i would suggest

Nirsoft Bulk File Changer

For Linux one could easily write a bash script and utilize the touch command to change multiple files.

The touch command is also available on Mac OS X, someone has written an automation task to do this but again this could be done on the terminal

FILES=./*
for f in $FILES
do
  echo "Processing $f file..."
  touch $f 
done

This bash script will touch every file in ascending order. You could add a "sleep" to the script if you wanted each file to have a different second value.

user@computer:/tmp/data$ ls -l

total 9028
-rw-r--r-- 1 user user  428800 Apr 19 12:18 File1
-rw-r--r-- 1 user user 4338800 Apr 19 12:18 File2
-rw-r--r-- 1 user user 4438800 Apr 19 12:18 File3
-rwxrwxrwx 1 user user      78 Apr 19 12:18 fix.sh
2
  • +1 @Christopher Wilson does Nirsoft Bulk File Changer change the date stamp of the files in a defined increment ascending through out. From a quick look at the website my impression is that yes it does bulk date stamp modification but the modification is the same applied to all the files, rather than applying an ascending value throughout a batch as I describe in my question. Apr 19, 2012 at 8:32
  • On many file systems (Ext4 comes to mind), the "last modified" and other time stamps are only kept at second precision as standard, so the above will in practice give all the files the exact same time stamp, which will return the Flickr selection back to file name order. The sleep 1 addition should suffice, but it will of course take a minute for every 60 files in the directory. Apr 20, 2012 at 6:21
1

" does Nirsoft Bulk File Changer change the date stamp of the files in a defined increment ascending through out."

The answer is YES. I did that to a batch of files. It can be done.

Select list of files in Total Commander or Windows Explorer and arrange in the order you want

Click and pull to Nirsoft Bulk File Changer

Adjust the date time of first file For example: Modified Date [/] 07-Apr-5 [/] 11:40:10 AM

[/] Add [1] [Minutes]

Click on [/] Date/time sequence mode

Must NOT click on [] Time is specified in GMT

Click on [Do it]

All the flies in the list are changed with Date Time Stamp with 1 minute change series in sequence. First file Added 1 minute Second file Added 2 minutes Third file Added 3 minutes and so on.....

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .