![]() |
How dont' show hidden system files - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How dont' show hidden system files (/thread-7459.html) |
How dont' show hidden system files - Mike Ru - Jan-11-2018 I'm using Windows now. I would like know how I can don't show hidden files in Windows. For example: import os print(os.listdir(r'C:/Users/mike/'))But I need to get only my files. How can I hide AppData, Ntuser.dat etc... ? RE: How dont' show hide system files - Larz60+ - Jan-11-2018 Go after the files you are interested in import glob def get_dir(dir): for file in glob.glob(dir): print(file) get_dir('Z:/python/forum/inspect/*.py')results:
RE: How dont' show hide system files - Mike Ru - Jan-11-2018 (Jan-11-2018, 12:44 PM)Larz60+ Wrote: Go after the files you are interested in I need all files and folders except hidden RE: How dont' show hidden system files - Larz60+ - Jan-11-2018 import os def get_dir(dir): return [file for file in os.listdir(dir) if not file.startswith('.')] print(get_dir('Z:/python/forum/inspect/')) RE: How dont' show hidden system files - Mike Ru - Jan-11-2018 (Jan-11-2018, 12:55 PM)Larz60+ Wrote: import os It shows all files and folders and hidden too. RE: How dont' show hidden system files - buran - Jan-11-2018 check this on SO for extensive discussion on cross platform hidden file detection https://stackoverflow.com/a/6365265/4046632 |