Blob Blame History Raw
--- trunk/tools/unoconv/unoconv	2010/10/20 11:21:12	9187
+++ trunk/tools/unoconv/unoconv	2010/10/25 08:46:13	9192
@@ -105,7 +105,7 @@
 __version__ = "$Revision$"
 # $Source$
 
-VERSION = '0.4'
+VERSION = '0.4svn'
 
 doctypes = ('document', 'graphics', 'presentation', 'spreadsheet')
 
@@ -333,7 +333,7 @@
         self.format = None
         self.importfilter = ""
         self.listener = False
-        self.outputpath = None
+        self.output = None
         self.pipe = None
         self.port = '2002'
         self.server = 'localhost'
@@ -347,9 +347,9 @@
         try:
             opts, args = getopt.getopt (args, 'c:d:e:f:hi:Llo:p:s:t:T:v',
                 ['connection=', 'doctype=', 'export', 'format=', 'help',
-                 'import', 'listener', 'outputpath=', 'pipe=', 'port=',
-                 'server=', 'timeout=', 'show', 'stdout', 'template',
-                 'verbose', 'version'] )
+                 'import', 'listener', 'output=', 'outputpath', 'pipe=',
+                 'port=', 'server=', 'timeout=', 'show', 'stdout',
+                 'template', 'verbose', 'version'] )
         except getopt.error, exc:
             print 'unoconv: %s, try unoconv -h for a list of all the options' % str(exc)
             sys.exit(255)
@@ -382,8 +382,11 @@
                 self.importfilter = arg
             elif opt in ['-l', '--listener']:
                 self.listener = True
-            elif opt in ['-o', '--outputpath']:
-                self.outputpath = arg
+            elif opt in ['-o', '--output']:
+                self.output = arg
+            elif opt in ['--outputpath']:
+                print >>sys.stderr, 'Warning: This option is deprecated by --output.' % arg
+                self.output = arg
             elif opt in ['--pipe']:
                 self.pipe = arg
             elif opt in ['-p', '--port']:
@@ -474,7 +477,7 @@
   -i, --import=string      set import filter option string
                              eg. -i utf8
   -l, --listener           start a listener to use by unoconv clients
-  -o, --outputpath=name    output directory
+  -o, --output=name        output basename, filename or directory
       --pipe=name          alternative method of connection using a pipe
   -p, --port=port          specify the port (default: 2002)
                              to be used by client or listener
@@ -656,10 +659,15 @@
 
             if not op.stdout:
                 (outputfn, ext) = os.path.splitext(inputfn)
-                if not op.outputpath:
+                if not op.output:
                     outputfn = outputfn + os.extsep + outputfmt.extension
+                elif os.path.isdir(op.output):
+                    outputfn = os.path.join(op.output, os.path.basename(outputfn) + os.extsep + outputfmt.extension)
+                elif len(op.filenames) > 1:
+                    outputfn = op.output + os.extsep + outputfmt.extension
                 else:
-                    outputfn = os.path.join(op.outputpath, os.path.basename(outputfn) + os.extsep + outputfmt.extension)
+                    outputfn = op.output
+
                 outputurl = unohelper.absolutize( self.cwd, unohelper.systemPathToFileUrl(outputfn) )
                 doc.storeToURL(outputurl, tuple(outputprops) )
                 info(1, "Output file: %s" % outputfn)