diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c32743..cff5bfb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ Click up arrow to go back to TOC. - Add word check in method man_get_vtt_words_index. - Add speed limit in trim in join-events. - Add method split_dst_lf_src_assfile to split bilingual subtitles file's events. +- Add current working directory support in file renaming. #### Changed(Unreleased) diff --git a/autosub/sub_utils.py b/autosub/sub_utils.py index c2bb1a75..d6d65abb 100644 --- a/autosub/sub_utils.py +++ b/autosub/sub_utils.py @@ -37,15 +37,19 @@ def str_to_file( Give a string and write it to file """ dest = output + ext = os.path.splitext(dest)[-1] if input_m: - while os.path.isfile(dest) or not os.path.isdir(os.path.dirname(dest)): + if not os.path.isdir(os.path.dirname(dest)): + dest = os.getcwd() + os.path.basename(dest) + while os.path.isfile(dest): print(_("There is already a file with the same path " "or the path isn't valid: \"{dest_name}\".").format(dest_name=dest)) dest = input_m( _("Input a new path (including directory and file name) for output file.\n")) dest = dest.rstrip("\"").lstrip("\"") - ext = os.path.splitext(dest)[-1] + if not os.path.isdir(os.path.dirname(dest)): + dest = os.getcwd() + os.path.basename(dest) dest = os.path.splitext(dest)[0] dest = "{base}{ext}".format(base=dest, ext=ext) diff --git a/docs/CHANGELOG.zh-Hans.md b/docs/CHANGELOG.zh-Hans.md index 663809f6..cd240219 100644 --- a/docs/CHANGELOG.zh-Hans.md +++ b/docs/CHANGELOG.zh-Hans.md @@ -63,6 +63,7 @@ - 添加字词检查在man_get_vtt_words_index。 - 添加速度限制在trim在join-events中。 - 添加split_dst_lf_src_assfile方法来分离同行双语字幕。 +- 添加当前工作路径文件名重命名支持。 #### 改动(未发布)