The DAM Forum
Welcome, Guest. Please login or register.
October 23, 2014, 01:34:59 PM

Login with username, password and session length
Search:     Advanced search
28018 Posts in 5138 Topics by 2910 Members
Latest Member: kbroch
* Home Help Search Login Register
+  The DAM Forum
|-+  Software Discussions
| |-+  Scripting
| | |-+  script for creating buckets
« previous next »
Pages: [1] Print
Author Topic: script for creating buckets  (Read 4974 times)
xopoe
Newbie
*
Posts: 18


View Profile
« on: July 17, 2006, 09:29:45 PM »

is there a script out there for organzing a mass of images into buckets?

ideally it would have the following components:

1) flexible size limit (cd, dvd, blu-ray, etc)
2) sort function (date created, modified, name, etc)
3) naming function

ideally it could also handle already existing folders in a similar fashion as standalone files.  and of course be smart enough to deal with things like xmp files.

if someone would make it, or if it already exists, i would be very happy.
Logged
matthewjheaney
Jr. Member
**
Posts: 52

674071051 matthewjheaney@msn.com matthewjheaney matthewjheaney
View Profile Email
« Reply #1 on: February 19, 2008, 12:51:59 PM »

is there a script out there for organzing a mass of images into buckets?

I have just written a script (written in vbscript) that I use from with xMedia, that partially does what you want.  I backup a subset of my catalog (e.g. "all the images from the shoot with Job ID = 1006") to DVDs, and this script automates the process of identifying how images within the catalog are allocated to DVDs.  The script will select a group of images having the requisite size, so then you can run a transfer files action on the selected files (to create the bucket), and after that, hide the files you just selected, and then you run the script again; repeat until of of your images have been processed.  (Future work includes automating this backup process more, but the version you have below is very handy for quickly selecting a group of images according to the size of the group.)

Note that I don't follow Peter's workflow advice exactly.  In my case, I backup images from a shoot (I use a 4-digit Job ID or "transmission code" to identify them) to their own set of DVDs.  Peter backs up all images (from across shoots) to a fixed-size bucket, and then when that's full create a new bucket.  (I don't do that, as I'm not a heavy shooter and I like to archive raw images to non-rewriteable media as quickly as possible, since I'm too disorganized to prevent myself from deleting or otherwise losing images. Ahem.)  But you could easily modify the script for that purpose (if you need help drop me a line).

Cheers,
Matt


--STX
'MJH_Select_Group_By_Size.vbs

Option Explicit

Const kTitle = "Select Size Group (MJH)"
Const kGb =      1000000000
Const kMaxSize = 4600000000  '4.6 Gb = my max bucket size

main

Sub main
   Dim app, cat, items, item
   Dim d, i, j, jj, basename, keys, items_array
   Dim total_size, requested_size, default_count, default_size, size

   Set app = CreateObject("ExpressionMedia.Application")
   Set cat = app.ActiveCatalog

   If (cat.Selection.Count > 0) Then
      Select Case MsgBox("Selection items already exist. Continue?", _
                         vbYesNo + vbQuestion, _
                         kTitle)
         Case vbYes
            'do nothing
         Case vbNo
            Exit Sub
      End Select
   End If

   Set items = cat.MediaItems
   Set d = CreateObject("Scripting.Dictionary")

   total_size = 0
   For Each item in items
      total_size = total_size + item.MediaInfo.FileSize
      basename = BasePart(item.Path)

      If Not d.Exists(basename) Then
         d.Item(basename) = Array  'element for this key is an empty array
      End If

      jj = d.Item(basename)
      ReDim Preserve jj(UBound(jj) + 1)
      Set jj(UBound(jj)) = item
      d.Item(basename) = jj
   Next

   default_count = Int((total_size + kMaxSize - 1) / kMaxSize)
   default_size = (total_size / default_count) / kGb
     
   requested_size = InputBox(CStr(items.Count) & " total items" & vbNewLine & _
                             CStr(d.Count) & " uniquely-named items" & vbNewLine & _
                             "Total size of all items is " & _
                             FormatNumber(total_size/(1000*1000*1000), 1) & _
                             " Gb" & vbNewLine & _
                             "Estimated number of DVDs is " & CStr(default_count) & _
                             vbNewLine & _
                             "What is the desired group size (in Gb)?", _
                             kTitle, _
                             FormatNumber(default_size, 1))

   If IsEmpty(requested_size) Then
      MsgBox "Operation cancelled.", vbOKOnly + vbInformation, kTitle
      Exit Sub
   End If
   
   'MsgBox "requested_size (in Gb): " & CStr(requested_size)                             

   requested_size = requested_size * kGb
   size = 0
   keys = d.Keys
   for i = LBound(keys) To UBound(keys)
      items_array = d.Item(keys(i))
      for j = LBound(items_array) To UBound(items_array)
         Set item = items_array(j)
         size = size + item.MediaInfo.FileSize
      Next

      If size > requested_size Then
         Exit For
      End if

      For j = LBound(items_array) To UBound(items_array)
         Set item = items_array(j)
         item.Selected = True
      Next
   Next
End Sub

function BasePart(Path)  'work-around for xMedia 1.0: Name property returns 8.3-style name instead of full name
    Dim p1, p2
    p2 = InStrRev(Path, ".", -1, vbTextCompare)
    p1 = InStrRev(Path, "\", p2 - 1, vbTextCompare) + 1
    BasePart = mid(Path, p1, p2 - p1)
End function
Logged
Roelof
Full Member
***
Posts: 127


View Profile WWW Email
« Reply #2 on: October 21, 2010, 09:50:00 AM »

On this topic some info about a tool wich can do the job?
http://thedambook.com/smf/index.php?topic=4673.0
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!