Looking for utility to batch change created/modified date of multiple files in ascending datetime (windows XP/7/Mac/Linux)

9,460

Solution 1

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).

Solution 2

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

Solution 3

" 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.....

Share:
9,460

Related videos on Youtube

therobyouknow
Author by

therobyouknow

I enjoy making software and applying technology to help myself and friends and family achieve things as well as earning a living doing it. github.com/therobyouknow linkedin.com/in/therobyouknow twitter.com/therobyouknow

Updated on September 18, 2022

Comments

  • therobyouknow
    therobyouknow over 1 year

    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.

    • Paul
      Paul about 12 years
      What OS are you using?
    • therobyouknow
      therobyouknow about 12 years
      @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.
    • Paul
      Paul about 12 years
      Ah yeah, didn't see it in the title, I have added the tags
    • Paul
      Paul about 12 years
      You want to change them to be incremental, but on what criteria? The name?
    • Daniel Andersson
      Daniel Andersson about 12 years
      Are you sure that Flickr doesn't use the EXIF data in the images themselves?
    • therobyouknow
      therobyouknow over 9 years
      Flickr now seem to be adding functionality that allows re-ordering photos in the Photostream, via the new Camera Roll menu option.
  • therobyouknow
    therobyouknow about 12 years
    +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.
  • Daniel Andersson
    Daniel Andersson about 12 years
    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.
  • therobyouknow
    therobyouknow about 12 years
    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.
  • zzapper
    zzapper over 10 years
    retime 3.jpg 2.jpg 1.jpg this gives time order 1.jpg,2.jpg,3.jpg