Skip to content

Instantly share code, notes, and snippets.

@sohamkamani
Created March 12, 2015 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sohamkamani/c01b4d1604c245eda623 to your computer and use it in GitHub Desktop.
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
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