python/scripts/aubiocut: add -o, --output directory option
authorPaul Brossier <piem@piem.org>
Sat, 11 Jan 2014 21:45:10 +0000 (17:45 -0400)
committerPaul Brossier <piem@piem.org>
Sat, 11 Jan 2014 21:45:10 +0000 (17:45 -0400)
python/scripts/aubiocut

index 48aa3e1..54724e1 100755 (executable)
@@ -106,6 +106,10 @@ def parse_args():
             action="store_true", dest="spectro", default=False,
             help="add spectrogram to the plot")
     """
+    parser.add_option("-o","--output", type = str,
+            metavar = "<outputdir>",
+            action="store", dest="output_directory", default=None,
+            help="specify path where slices of the original file should be created")
     parser.add_option("-v","--verbose",
             action="store_true", dest="verbose", default=True,
             help="make lots of noise [default]")
@@ -164,6 +168,10 @@ if __name__ == '__main__':
         # generate output filenames
         import os
         source_base_name, source_ext = os.path.splitext(os.path.basename(source_file))
+        if options.output_directory != None:
+            if not os.path.isdir(options.output_directory):
+                os.makedirs(options.output_directory)
+            source_base_name = os.path.join(options.output_directory, source_base_name)
         def new_sink_name(source_base_name, timestamp):
             return source_base_name + '_%02.3f' % (timestamp) + '.wav'
         # reopen source file