Skip to content

Instantly share code, notes, and snippets.

@RickyCook
Last active August 29, 2015 14:08
Show Gist options
  • Save RickyCook/cc587078861121b3f2e3 to your computer and use it in GitHub Desktop.
Save RickyCook/cc587078861121b3f2e3 to your computer and use it in GitHub Desktop.
Pytho one line file match in directory
# 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