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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -