Page 1 of 1

watch a folder for change

Posted: Sun Mar 27, 2011 11:10 pm
by andreacremaschi
Hi,
I am filling up a folder with live input movie files from an external app, and I would like m8 to update the media bin when the folder receives a new movie file. Is it possible? How? Scripting, maybe? Has anybody ever tried?

Posted: Mon Mar 28, 2011 3:57 pm
by anomad
. yes, it is possible w/scripting. i've done a similar thing with pictures... it depends on if you're replacing media or just adding it to the media set in general, the workflow is

. create a module that scans the 'incoming' folder (in PeriodicalEvent - i checked every 30 seconds so as not to bog the system down)

. when you find a new media, load it into either an empty media slot or replace an existing media

. you need to import the os library in Init()
import os

. here is a code snippet where i the paths to all the clips in a directory into an array

Code: Select all

   if os.path.isdir(loadPath) :
      for fn in os.listdir(loadPath):
         myFN = loadPath+"/"+fn
         clipNames.append(myFN)
         clipUsed.append(indx)
         indx += 1
      module.setValue('loadStat','%i clips found' % indx)
      print "found ", indx, "clips !"


. loadPath is set in the module to the location of the clips
. i verify the directory exists, then loop through all the files in the directory
. clipNames is an array of all the file names
. clipUsed is an array of which media files i'm using - in another module i randomly grab 16 files and load them into a media bank and 'pop' their values out of the secondary array. when that secondary array is empty, i recreate it (based on the size of clipNames) and repeat the process
. i send a message to the module saying how many clips i've found.

. hth

-james
(a nomad. )

Posted: Mon Mar 28, 2011 10:02 pm
by andreacremaschi
Thank you james for your precious help! I will work on this.
a.