Skip to content

Commit

Permalink
updated filename formatting to avoid crashing with spaces and dots
Browse files Browse the repository at this point in the history
  • Loading branch information
joeperpetua committed Jun 21, 2021
1 parent 406a334 commit c49626a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def openWithSub(path, name):

def unZip(path, name):
print('unzip :' + path + "\nwith name : " + name)

cmd7z = '"' + sevenZipExecutable + '" x "' + path + '" -bsp1 -y -o' + destination

app.info("unzipping...")
Expand Down Expand Up @@ -226,6 +227,21 @@ def check(btn):
app.warn("File not supported /// The tool supports only 'dat', 'zip', 'rar', 'tar', '7z', 'gzip' file extensions...")
return 0

# format file name to remove spaces and dots
tempPath = path.split('/')
tempPath = tempPath[len(tempPath)-1]
if ' ' in tempPath:
tempPath = tempPath.replace(' ', '')

if '.' in tempPath:
occurences = tempPath.count('.')
tempPath = tempPath.replace('.', '', occurences - 1)

# now rename file with formatted name
os.rename(path,tempPath)

path = tempPath

# C:\tickets\name\
destination += name + bar

Expand Down

0 comments on commit c49626a

Please sign in to comment.