Hacker News new | ask | show | jobs
by badboy 5102 days ago
Just change the current working directory in the script before running the task. No need to move them then.
1 comments

You're quite right. But we're still left with many problems stemmed from not having control on the sequence length and file names. I've tried it with a background task and the results are super flimsy. The time that the camera takes to be ready varies which then makes the number of files generated vary, sometimes the process is killed before imagesnap finished saving current file resulting in a corrupted image. And the file names outputted are really begging for some post-processing renaming.

Here's what I have for what it's worth:

    #!/usr/bin/env ruby
    require 'rubygems'
    require 'systemu'
    Dir.chdir(File.expand_path('~/.gitshots'))
    cam_warm_up_time = 2
    num_snaps = 6
    interval = 0.2
    systemu "imagesnap -w #{cam_warm_up_time} -t #{interval}" do |cid|
      sleep cam_warm_up_time + interval * num_snaps
      Process.kill 9, cid
      exit 0
    end