Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import subprocess as sp
- allFiles = []
- currentFile = ""
- #workingDir = "G:\Games\Console\Sony - PSP"
- workingDir = "H:\Test"
- #fileType = ".iso"
- fileType = ".bin"
- archiverPath = 'C:\\x64\\7za.exe'
- def getFiles(workingDir):
- for root, dirs, files in os.walk(workingDir):
- for file in files:
- if file.endswith(fileType):
- allFiles.append(os.path.join(root, file))
- #print(os.path.join(root, file))
- def compress(allFiles):
- for i in allFiles:
- #os.system('C:\\x64\\7za.exe a -mx9 -ms=off ' + '"' + i.replace('.iso', '.7z') + '"' + ' ' + '"' + i + '"')
- compress = sp.run([archiverPath, 'a', '-mx9', '-ms=off', i.replace(fileType, '.7z'), i], stdout = sp.PIPE, stderr = sp.STDOUT)
- print('C:\\x64\\7za.exe a -mx9 -ms=off ' + '"' + i.replace('.iso', '.7z') + '"' + ' ' + '"' + i + '"')
- test = sp.run([archiverPath, 't', i.replace(fileType, '.7z')], stdout=sp.PIPE, stderr=sp.STDOUT)
- if test.returncode >= 2:
- print ('Broken')
- else:
- os.remove(i)
- getFiles(workingDir)
- compress(allFiles)
- print (allFiles)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement