image sequences in a consolidated form in Terminal OSX

Discussion in 'OS X' started by eLoup, Feb 5, 2013.

  1. macrumors newbie

    Joined:
    Jul 24, 2002
    #1
    Does anyone have any pointers for listing sequences as a 'consolidated' form in OSX Terminal ?

    I work with Nuke (The Foundry) on osx 10.7, but this sort of question is probably one that a lot of guys working with osx or linux workstations in vfx ask, I suppose.

    Example : if I have a folder named '/Volumes/mydisk/render' that has one sequence of images, five TIFF files, I would type 'ls' in the '/render' directory and get

    0001.tiff
    0002.tiff
    0003.tiff
    0004.tiff
    0005.tiff

    but what I want to see is something like this :

    0001-0005.tiff or [1-5].tiff

    in the same way that I want to SEE files listed as so, I would also want to be able to delete 'rm', copy 'cp', or move 'mv', using the same sequence command.

    Example : “copy frame ranges from one directory to another”

    cp /Volumes/mydisk/render/[2-4].tiff /Volumes/disk2/folder

    which would copy images 0002.tiff, 0003.tiff, 0004.tiff over to my example folder “/Volumes/disk2/folder/ “

    I think most of us understand why this is desirable, but I'm not finding anything on the intenet that's pointing me to any solutions....

    anyone ?

    When you have a single folder containing upwards of 50,000 images or more (tiff, dpx, exr etc) and you type 'ls' the Terminal leaves a lot to be desired... At the same time, opening a Finder window is always panic inducing, especially if you have to drag and drop a selection from one Finder window to another. It's fine if you've got, say 1000 images in your folder. But anything more and it can really become ball busting.

    Thanks to anyone who may point me to the right direction !
     
  2. macrumors 65816

    Joined:
    Nov 26, 2007
    Location:
    Austin, TX
    #2
    For copying and other file manipulation, you should be able to use regular expressions. For example "cp 000[1-4].tiff dest_dir/" Go read about regular expressions to find out how to create more sophisticated expressions.

    As far as listing your files. You could probably pipe ls through and awk script (or whatever scripting language you prefer) to get the output you want. I know of no built-in command which would list the files as you desire.
     
  3. thread starter macrumors newbie

    Joined:
    Jul 24, 2002
    #3
    Thanks ScoobyMcDoo for the suggestion, but your expression isn't working for me. I'm trying all sorts of things but the best I seem to be able to do is copy one, or two files - It seems impossible to specify a range ... ? Any help ? I am a very basic Terminal user and have no unix/linux experience, so it goes without saying that I have no idea what an awk script is. I started trying things like cp [00013 n+1 00018].jpg /destinationfolder

    hoping in some naive way that there was a way to "increment by n+1" from one number (00013) to another (00018)... of course this doesn't work....

    anyone have any ideas ?
     
  4. macrumors 65816

    Joined:
    Nov 26, 2007
    Location:
    Austin, TX
    #4
    I recommend you google the term "regular expression". You will find multiple tutorials on learning how to use them. Trying to guess at how regular expressions work will be about a fun and productive as rubbing a cheese grater on your head - RTFM.
     
  5. macrumors 6502a

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #5
    No this is not correct. The shell does not use regular expressions. It uses something called "globbing". They are not the same.

    As for the original question, you can't get a numerical sequence out of globbing. If you want a purely numerical sequence then you will have to write a script (in some language of your choice) to perform the operations.

    If you want to see what you can do in the shell, then "man bash". Look for the section on 'Pathname Expansion'.

    The expansion choices are *, ?, {}, and []. * matches all characters (including none). ? matches exactly one character. {} matches a list of characters, and [] matches a range of single characters.

    005{1,2,7} would match "0051 0052 0057"

    005[0-2] would match "0050 0051 0052"

    If you want files 54 to 71, you'd need an expression like

    005[4-9] 006% 007{0,1}
     
  6. macrumors 65816

    Joined:
    Nov 26, 2007
    Location:
    Austin, TX
    #6
    Sorry for the brain fart -- I knew that. mfram, thanks for the correction.
     
  7. macrumors 6502a

    mw360

    Joined:
    Aug 15, 2010
    #7
    You might want to try writing a Python script to do this. Somebody's trying to do something similar (but not quite the same) here, and gets what looks like a working solution.

    You might think learning to make Python scripts sounds like overkill but knowing a bit of Python can vastly improve your Nuke experience.
     

Share This Page