python 3.x - subprocess.call() to remove except *.txt files -


i have shell command:

rm !(*.esla.ass|*.mp4|*.txt|*.sh|*.py) 

i trying with:

files = [i in glob.glob("*") if not in ('*.esla', '*.mp4')] subprocess.call(['rm','-r'] + files) 

but deletes me everything

can me please???

you're not using glob file names, '' interpreted string literal in case you're deleting in glob(''). use extension like:

[filename filename in glob('*') if filename.split('.')[-1] not in ['.esla', '.mp4']] 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -