Created
March 12, 2015 14:41
-
-
Save sohamkamani/c01b4d1604c245eda623 to your computer and use it in GitHub Desktop.
Lists all directories and stores them as a variable in a js file
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 | |
import os.path | |
d='.' | |
dirs = [os.path.join(d,o) for o in os.listdir(d) if os.path.isdir(os.path.join(d,o))] | |
dir_sanitized = [] | |
for dir in dirs: | |
dir_sanitized.append(dir.split('/')[1]) | |
dirmap = open('dirmap.js','w') | |
dirmap.write("var directories=["); | |
for dir in dir_sanitized: | |
if 'origin-' in dir: | |
link_string = '"' + dir + '",' | |
dirmap.write(link_string) | |
dirmap.write('"end"]') | |
dirmap.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment