Skip to content

Commit

Permalink
remove trailing dots and spaces from directory names (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Mar 19, 2020
1 parent 2c3b9e1 commit 9159cb8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gallery_dl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,13 +726,17 @@ def _enum_file(self):

def set_directory(self, kwdict):
"""Build directory path and create it if necessary"""
windows = os.name == "nt"

# Build path segments by applying 'kwdict' to directory format strings
segments = []
append = segments.append
try:
for formatter in self.directory_formatters:
segment = formatter(kwdict).strip()
if windows:
# remove trailing dots and spaces (#647)
segment = segment.rstrip(". ")
if segment:
append(self.clean_segment(segment))
except Exception as exc:
Expand All @@ -747,7 +751,7 @@ def set_directory(self, kwdict):
directory += sep
self.directory = directory

if os.name == "nt":
if windows:
# Enable longer-than-260-character paths on Windows
directory = "\\\\?\\" + os.path.abspath(directory)

Expand Down

0 comments on commit 9159cb8

Please sign in to comment.