Created
September 20, 2018 16:31
-
-
Save R4wm/b3ec72ae7fc52453a7f92576e8f571a7 to your computer and use it in GitHub Desktop.
simple script to sort files in local dir, can be changed to take arg or even walk directory
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
#!/usr/bin/env python | |
import os | |
import json | |
filelist = [] | |
for i in os.listdir('.'): | |
if i.endswith(".json"): | |
filelist.append(i) | |
for f in filelist: | |
with open(f) as l_unsorted_file: | |
l_unsorted_content = json.loads(l_unsorted_file.read()) | |
with open(f, 'w') as l_sortme: | |
l_sortme.write(json.dumps(l_unsorted_content, indent=4, sort_keys=True)) | |
print("Sorted {}".format(f)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment