Skip to content

Commit

Permalink
Add current working directory support in file renaming.
Browse files Browse the repository at this point in the history
  • Loading branch information
BingLingGroup committed Oct 1, 2020
1 parent 26f740a commit ff0f6ba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
8 changes: 6 additions & 2 deletions autosub/sub_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.zh-Hans.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
- 添加字词检查在man_get_vtt_words_index。
- 添加速度限制在trim在join-events中。
- 添加split_dst_lf_src_assfile方法来分离同行双语字幕。
- 添加当前工作路径文件名重命名支持。

#### 改动(未发布)

Expand Down

0 comments on commit ff0f6ba

Please sign in to comment.