Last active
August 29, 2015 14:00
-
-
Save pavelk2/11252751 to your computer and use it in GitHub Desktop.
This file contains 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
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') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks a lot :). it is really useful. actually 4 those who wants to create cache.manifest for html offline.