You are here

batch processing and sorting of arrays

Hi,

I'm creating a script-fu to do batch processing. I'm using file-glob to create the array of files.

My problem is the array of file locations (i.e. (cadr (file-glob "/pattern/*.jpg" 1)) ) is not sorted out. I get files in the wrong order. That is a problem in my case where I want to process the photos in the order they were captured.

the goal of the script is to transform a timelapse of stars "turning" in the sky into a timelapse of star trails (stars are then forming lines in the sky, and those lines are growing with time)
this is then very important to process the file in the order they were captured.

So ! questions.
is there a way to sort out the array of strings mentioned earlier ?
how file-glob is creating the array of strings ? is there a way to sort out the files prior to running the script ?

The following procedure implements a simple insert sort algorithm. This approach is quite fast for up to about two dozen names, and provides reasonably acceptable speeds for up to about 200 names.

(define (name-sort lis)
  (define (insert name sorted)
    (if (null? sorted)
      (list name)
      (if (string<? name (car sorted))
        (cons name sorted)
        (cons (car sorted) (insert name (cdr sorted))) )))
  (if (null? lis)
        '()
        (insert (car lis) (name-sort (cdr lis))) ))

For situations where you have thousands of names to sort and execution speed is important, I would suggest implementing a merge sort (e.g., http://en.literateprograms.org/Merge_sort_%28Scheme%29) with the appropriate predicate.

.. but you will find that python scripts can use the whole range of python functionality and additional modules; including the built-in sort, and also, in your case, modules to use the EXIF data in the pictures (so you can base your sort on that, which is more reliable that the file timestamp).

you can see the results here : http://youtu.be/erkdKzCjvzc , and there : http://youtu.be/h_TaptozltU .

I have to find some time to get into the python language, seems very powerful.

Subscribe to Comments for "batch processing and sorting of arrays"