Created
October 4, 2017 20:55
-
-
Save jarun/2bcb5238bc47111c22f783254a98fd5d to your computer and use it in GitHub Desktop.
Remove executable permission for media files recursively
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import stat | |
extns = ['.aac', '.avi', '.flac', '.m3u', '.m4a', '.mkv', '.mp3', '.mp4', '.smi', '.srt', '.sub', '.webm', '.wma'] | |
for root, dirs, files in os.walk('.'): | |
for entry in files: | |
fname, ext = os.path.splitext(entry) | |
ext = ext.lower() | |
if ext in extns: | |
abspath = os.path.join(root, entry) | |
if os.access(abspath, os.X_OK): | |
fperms = stat.S_IMODE(os.lstat(abspath).st_mode) | |
os.chmod(abspath, fperms & ~stat.S_IXUSR & ~stat.S_IXGRP & ~stat.S_IXOTH) | |
print(abspath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment