Send mdfind output into script file

I'm using mdfind to list images according to their orentation, thus:-

mdfind  " kMDItemOrientation == 1" -onlyin "/Users/me/Documents/STUDY/AskForum" 

which outputs

/Users/me/Documents/STUDY/AskForum/01 (5).jpg
/Users/me/Documents/STUDY/AskForum/01 (4).jpg
/Users/me/Documents/STUDY/AskForum/01 (2).jpg
/Users/me/Documents/STUDY/AskForum/01 (1).jpg

and this

mdfind  " kMDItemOrientation == 0" -onlyin "/Users/me/Documents/STUDY/AskForum"

which outputs

/Users/me/Documents/STUDY/AskForum/01 (3).jpg

What I want to do is write the mdfind output into a script file thus:-

mv "/Users/me/Documents/STUDY/AskForum/01 (6).jpg" Ori-1
mv "/Users/me/Documents/STUDY/AskForum/01 (5).jpg" Ori-1
mv "/Users/me/Documents/STUDY/AskForum/01 (4).jpg" Ori-1
mv "/Users/me/Documents/STUDY/AskForum/01 (2).jpg" Ori-1
mv "/Users/me/Documents/STUDY/AskForum/01 (1).jpg" Ori-1


mv "/Users/me/Documents/STUDY/AskForum/01 (3).jpg" Ori-0

Can I do this from a UNIX commandline in Terminal on Mac OS X 10.7.5

Ta

waggs

Seems pretty simple:

$ mdfind ... | while read f
do
 mv "$f" dest_dir
done

Perfect. Thanks.

That's a shell keeper, and you can read N+ fields into N variables, you can change $IFS in the while subshell to change field dividers, it has low latency and no upper limit on lines processed. It works in bash, ksh, and who knows, maybe sh. Avoid "for f in `make_all_files`; do ... done". Bash has a read -a to load all fields into one predefined typedef array variable.