Last active
June 17, 2022 23:47
-
-
Save langf00rd/15e1f291be7d4e513b852c27af15e4e8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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.path | |
| import json | |
| from tkinter import Tcl | |
| current_path = os.path.abspath(os.getcwd() + "/metadata") | |
| files = os.listdir(current_path) | |
| sorted_files = Tcl().call("lsort", "-dict", files) | |
| index = 0 | |
| name = "Meta Mini" | |
| extension = ".jpg" | |
| url = "https://ipfs.infura.io/ipfs/abc/" | |
| description = "description text" | |
| for file in sorted_files: | |
| # if (str(file) != "['729.json',") and (str(file) != "'.DS_Store',"): | |
| if str(file) != "'.DS_Store',": | |
| new_file = ( | |
| str(file) | |
| .replace("'", "") | |
| .replace(",", "") | |
| .replace("[", "") | |
| .replace("]", "") | |
| ) | |
| index += 1 | |
| if new_file == "730.json": | |
| index += 1 | |
| if new_file == "729.json": | |
| index = 729 | |
| with open(os.path.join(current_path, new_file), "r+") as f: | |
| data = json.load(f) | |
| data["image"] = url + str(index) + extension | |
| data["id"] = index | |
| data["name"] = name + "_" + str(index) | |
| data["description"] = description | |
| f.seek(0) | |
| json.dump(data, f, indent=4) | |
| f.truncate() | |
| print("done ... ", new_file, index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment