Last active
August 29, 2015 14:08
-
-
Save RickyCook/cc587078861121b3f2e3 to your computer and use it in GitHub Desktop.
Pytho one line file match in directory
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
# Find files in the current directory that do not contain a '.' | |
(item for sublist in ((os.path.join(r,f) for f in fs if '.' not in f) for r, _, fs in os.walk('.')) for item in sublist if os.path.isfile(item)) | |
# Add '.log' to the end of any file that has no extension. Probably easier with `rename` command :| | |
[shutil.move(src, '%s.log' % src) for src in (item for sublist in ((os.path.join(r,f) for f in fs if '.' not in f) for r, _, fs in os.walk('.')) for item in sublist if os.path.isfile(item))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment