Download a lot of compressed files and write a script
The WinRAR command is used in Python, so generally compressed files are supported.
Some compressed files have no corresponding libraries in Python.
You must add WinRAR to the path environment variable first.
Save the code as RAR. py
Used in DOS, such as RAR. py "D:/a B/C" mkdir
# RAR. PY <br/> # decompress with WinRAR <br/> # arguments: filename directory opt <br/> # opt = 'mkdir' to create directory with the correspond filename <br/> # opt = 'direct' to decompress RAR files in current directory <br/> # opt = 'mk & del 'to mkdir and delete RAR file <br/> Import OS <br/> Import sys <br/> If Len (sys. argv )! = 3: <br/> Print ('wrong arguments/N') <br/> Print ('rar. PY directory opt/N') <br/> Print ('opt =/'mkdir/'to create directory with the correspond filename/N ') <br/> Print ('opt =/'direct/'to decompress RAR files in current directory/N ') <br/> Print ('opt =/'mk & del/'to mkdir and delete RAR file/N') <br/> exit (0) </P> <p> #-ibck, minimized when running <br/> opt = sys. argv [2] <br/> OS. chdir (sys. argv [1]) <br/> for file in OS. listdir ('. '): <br/> If OS. path. isfile (File) and OS .path.splitext(file=%1}{'.rar ': <br/> If opt = 'mkdir ': <br/> cmd = 'winrar X-ibck "'+ file +'" '+' "'+ OS. path. splitext (File) [0] + '"//' <br/> OS. system (CMD) <br/> Elif opt = 'direct ': <br/> cmd = 'winrar X-ibck "'+ file +'" '<br/> OS. system (CMD) <br/> Elif opt = 'mkdel ': <br/> cmd = 'winrar X-ibck "'+ file +'" '+' "'+ OS. path. splitext (File) [0] + '"//' <br/> OS. system (CMD) <br/> OS. remove (File) <br/> else: <br/> Print ('wrong option') </P> <p>