View Single Post
Marvelous, Thanks for that. I have modify a little (add set front doc) and add the ability to manage folders and subfolders. After, just need to sync the .pdf with the nas and remove them. Thanks a lot, here is the final script :

Code:
  1 osascript -e 'tell application id "OOut" to close documents' #  > /dev/null 2>&1;  
2 for f in `find /Users/Pamphile/Desktop/a -name "*.oo3" -type d ` #  /Users/Pamphile/Desktop/*.oo3 
  3 do   
  4         open "$f"
  5         sleep .1
  6 osascript -e 'tell application id "OOut" to activate'
  7         osascript -e 'tell application id "OOut" to export front document as "OORTFPboardType" to "~/tmp.rtf"' #  > /dev/null 2>&    1;
  8         /System/Library/Printers/Libraries/convert -f  ~/tmp.rtf -o "$f".pdf #  > /dev/null 2>&1;
  9         osascript -e 'tell application id "OOut" to close documents' # > /dev/null 2>&1;
 10 done
 11 rm ~/tmp.rtf


Quote:
Originally Posted by RobTrew View Post
You can get the file name from the shell process which loops through the .003 files.

If you can make sure that all documents in oo3 are closed, you can then assume that the newly opened one is the front document.

Don't have time for testing or debugging today, but you should be able to put something along these general lines in a shell script:

Code:
osascript -e 'tell application id "OOut" to close documents' > /dev/null 2>&1;
for f in *.oo3 
do 
	open "$f"
	sleep .5 # You may be able to reduce or remove this
	osascript -e 'tell application id "OOut" to export front document as "OORTFPboardType" to "~/tmp.rtf"' > /dev/null 2>&1;
	/System/Library/Printers/Libraries/convert -f  ~/tmp.rtf -o "$f".pdf > /dev/null 2>&1;
	osascript -e 'tell application id "OOut" to close documents' > /dev/null 2>&1;
done
rm ~/tmp.rtf