This is my first post here although I’ve come here for solutions very very frequently!
I couldn’t find an answer to a question I have. Maybe I’m using the wrong tags in my search :/ Anyway, please, pardon me in advance if the question was asked before.
I want to create a small script to automatically upload photos and videos from a folder. I currently use a perl script called “flickr_upload”, found in the macports directory.
Let’s say I have 12 files in a directory. I want to split these 12 files in 3 batches of 4 files and launch 3 command-lines in parallel using xterm for example.
How can automatically split a list by just specifying the number of batches?
Regards
Edit: instead of writing:
flickr_upload photo01.jpg photo02.jpg photo03.jpg
I’d like to have:
flickr_upload photo01.jpg
flickr_upload photo02.jpg
flickr_upload photo03.jpg
by writing something like:
split -n 3 ./*.jpg | xterm flickr_upload -
xargscan do this for you.for instance,
seq 10 | xargs echoechos all 10 “arguments” at once. Butseq 10 | xargs -n 3 echodoes them 3 at a time:I don’t know anything about flickr_upload or what “macports” might be, but presumably you can do this:
ls *jpg | xargs -n 3 flickr_upload