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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -