From 7e6da3c2bdea599f5bc1323b7be0bb8466b7181d Mon Sep 17 00:00:00 2001 From: mousebot Date: Sun, 26 Apr 2020 19:17:41 -0300 Subject: [PATCH] fix batchfile path --- mkv_this/functions.py | 8 +++++--- mkv_this/mkv_this.py | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mkv_this/functions.py b/mkv_this/functions.py index 0493f39..aeb1382 100644 --- a/mkv_this/functions.py +++ b/mkv_this/functions.py @@ -102,6 +102,7 @@ def writesentence(tmodel, args_sen, args_out, args_over, args_len): # functions for directory: def dir_list(directory): + "fetch list of text files from a directory" # create a list of files to concatenate: matches = [] if os.path.isdir(directory) is True: @@ -116,10 +117,11 @@ def dir_list(directory): return matches # returns a LIST of filenames -# feed this one the matches list: -def dir_cat(matchlist, batchfile): +# feed this the matches list: +def dir_cat(matchlist, bulkfile): + "takes a list of files, concatenates their contents into a single file" # concatenate into batchfile.txt: - with open(batchfile, "w") as outfile: + with open(bulkfile, "w") as outfile: for fname in matchlist: try: with open(fname, encoding="utf-8") as infile: diff --git a/mkv_this/mkv_this.py b/mkv_this/mkv_this.py index 6a00b53..0f1f535 100755 --- a/mkv_this/mkv_this.py +++ b/mkv_this/mkv_this.py @@ -147,7 +147,8 @@ def main(): elif args.directory: matchlist = dir_list(args.infile) # place batchfile.txt in user-given directory: - batchfile = os.path.dirname(args.infile) + os.path.sep + "batchfile.txt" + #batchfile = os.path.dirname(args.infile) + os.path.sep + "batchfile.txt" + batchfile = args.infile + os.path.sep + "batchfile.txt" dir_cat(matchlist, batchfile) text = read(batchfile) os.unlink(batchfile) @@ -167,9 +168,10 @@ def main(): elif args.directory: matchlist = dir_list(args.infile) # place batchfile.txt in user-given directory: - batchfile = os.path.dirname(args.infile) + os.path.sep + "batchfile.txt" + batchfile = args.infile + os.path.sep + "batchfile.txt" dir_cat(matchlist, batchfile) text = read(batchfile) + os.unlink(batchfile) # or normal: else: text = read(args.infile) @@ -209,9 +211,10 @@ def main(): elif args.directory: matchlist = dir_list(args.infile) # place batchfile.txt in user-given directory: - batchfile = os.path.dirname(args.infile) + os.path.sep + "batchfile.txt" + batchfile = args.infile + os.path.sep + "batchfile.txt" dir_cat(matchlist, batchfile) text = read(batchfile) + os.unlink(batchfile) # or local: else: text = read(args.infile)