Python Rar All File In Directory, Each File Different Directory
Question: It feels like this is a colossally stupid question, but the documentation for
rar as a whole is pretty sketchy, and using python to rar pulls an insane
number of hits, none of them even seem to be attempting what I'm trying to do
(which I find somewhat odd).

I have a directory with a bunch of files: FILE_1.ext FILE_2.ext FILE_3.ext ...
FILE_N.ext

The names aren't necessarily uniform, neither are the extensions. I'm looking
for a python script to: for all files in directory that don't start with . rar
a -m0 -R -v1g FILE_NAME.rar "FILE_NAME" #Note: FILE_NAME.rar doesn't have the
".ext"

The "rar a -m0 -R -v1g FILE_NAME.rar "FILE_NAME"" part is what I use when I'm
sending a shell command, for one file, and I have to enter the FILE_NAME
myself, etc. Hasn't been a problem, but now I'm dealing with a lot of large
files, and it's too much to enter them all in one-by-one, but I need to have
each file be it's own volume.


Answer: How about:

    
    
        import os
        for file_n in os.listdir(DIRECTORY_NAME):
             if not file_n.startswith('.') and not file_n.endswith('.rar'):
                  os.system('rar a -m0 -R -v1g %s.rar "%s"' %(os.path.splitext(file_n)[0], file_n))
    

