Answer the question
In order to leave comments, you need to log in
Archiving rar via python doesn't work but works via cmd, what should I do?
import os
import sys
my_loc, me = os.path.split(sys.argv[0])
print(my_loc)
target = "C:\\Users\\Cat Kingdom\\Desktop\\Scripts"
rarloc = f'C: \\Users\\Cat Kingdom\\Desktop\\{me}.rar'
command=f'"c:\\program files\\winrar\\rar.exe" a "{rarloc}" "{target}"'
task = os.system(command)
if not task:
print('Success')
else :print(task)
# output = 1
'''
command = '"c:\\program files\\winrar\\rar.exe" a "C:\\Users\\Cat Kingdom\\Desktop\\counter.py.rar" "C:\\Users\\Cat Kingdom\\Desktop\\Scripts"'
If in cmd type "c:\\program files\\winrar\\rar.exe" a "C:\\Users\\Cat Kingdom\\Desktop\\counter.py.rar" "C:\\Users\\ Cat Kingdom\\Desktop\\Scripts" then works fine
Question - why doesn't it work through python? '''
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question