Skip to content

Commit

Permalink
Merge bfc452f into e23ca39
Browse files Browse the repository at this point in the history
  • Loading branch information
schdub committed Mar 19, 2018
2 parents e23ca39 + bfc452f commit fb8cad7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pysrt/commands.py
Expand Up @@ -178,8 +178,11 @@ def split(self):

def create_backup(self):
backup_file = self.arguments.file + self.BACKUP_EXTENSION
if not os.path.exists(backup_file):
shutil.copy2(self.arguments.file, backup_file)
backup_idx = 1
while os.path.exists(backup_file):
backup_file = self.arguments.file + ('.%i' % backup_idx) + self.BACKUP_EXTENSION
backup_idx += 1
shutil.copy2(self.arguments.file, backup_file)
self.output_file_path = self.arguments.file
self.arguments.file = backup_file

Expand Down

0 comments on commit fb8cad7

Please sign in to comment.