Skip to content

Instantly share code, notes, and snippets.

@petarnikolovski
Last active August 20, 2019 08:43
Show Gist options
  • Save petarnikolovski/e2265cdadc4f9fce071d8732096561bf to your computer and use it in GitHub Desktop.
Save petarnikolovski/e2265cdadc4f9fce071d8732096561bf to your computer and use it in GitHub Desktop.
Walk and replace
import os
import uuid
tmp = '/tmp/{}'.format(uuid.uuid4())
files_root = os.getcwd()
for root, dirs, files in os.walk(files_root):
root_path = root.replace(files_root, '')
root_path = root_path[1:] if root_path.startswith('/') else root_path
for file in files:
print(os.path.join(tmp, root_path, file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment