Skip to content

Instantly share code, notes, and snippets.

@pavelk2
Last active August 29, 2015 14:00
Show Gist options
  • Save pavelk2/11252751 to your computer and use it in GitHub Desktop.
Save pavelk2/11252751 to your computer and use it in GitHub Desktop.
import os
directory = '/Users/pavelk/Dropbox/Design/SocialInformatics'
output_file = 'output/listing.txt'
def recurseFolderListing(directory):
listing = []
for dirname, dirnames, filenames in os.walk(directory):
# print path to all subdirectories first.
for subdirname in dirnames:
if subdirname[0]!='.':
listing.append(os.path.join(dirname, subdirname))
# print path to all filenames.
for filename in filenames:
if filename[0]!='.':
listing.append(os.path.join(dirname, filename))
# Advanced usage:
# editing the 'dirnames' list will stop os.walk() from recursing into there.
if '.git' in dirnames:
# don't go into any .git directories.
dirnames.remove('.git')
return listing
with open(output_file, 'w') as myFile:
for item in recurseFolderListing(directory):
myFile.write(str(item)+'\n')
@imana97
Copy link

imana97 commented Apr 24, 2014

Hi, thanks a lot :). it is really useful. actually 4 those who wants to create cache.manifest for html offline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment