Created
July 17, 2020 05:41
-
-
Save xjasonlyu/b6a5794f7c8d0b6c458eba1845f646d3 to your computer and use it in GitHub Desktop.
Add .ignore file for emby/jellyfin
This file contains hidden or 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 sys | |
| def touch(filename): | |
| with open(filename, 'w') as f: | |
| pass | |
| def find_dot_folder(folder): | |
| for root, dirs, files in os.walk(folder): | |
| if not dirs: | |
| continue | |
| for d in dirs: | |
| if d.startswith('.'): | |
| yield os.path.join(root, d) | |
| def add_ignore_file(folder): | |
| _ignore = '.ignore' | |
| for d in find_dot_folder(folder): | |
| filename = os.path.join(d, _ignore) | |
| # continue if already exists | |
| if os.path.exists(filename): | |
| continue | |
| # print & touch | |
| print(filename) | |
| touch(filename) | |
| def main(): | |
| # default | |
| folder = '.' | |
| # get arguments | |
| if len(sys.argv) > 1: | |
| folder = sys.argv[1] | |
| add_ignore_file(folder) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment