Skip to content

Commit 6629b80

Browse files
committed
fm_duplicate: create folder paths up to destination
duplicating foo/bar/file to foo/baz/file didn't work if the folder baz didn't exists. fixes #80
1 parent b98a222 commit 6629b80

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

commands/duplicate.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ def duplicate(self, dst, input_path):
4646
sublime.error_message("Destination is the same with the source.")
4747
return
4848

49+
# remove right trailing slashes, because os.path.dirname('foo/bar/')
50+
# returns foo/bar rather foo/
51+
dst = dst.rstrip("/")
52+
53+
os.makedirs(os.path.dirname(dst), exist_ok=True)
54+
4955
if os.path.isdir(self.origin):
5056
if not os.path.exists(dst):
5157
shutil.copytree(self.origin, dst)

0 commit comments

Comments
 (0)