Skip to content

Instantly share code, notes, and snippets.

@Kas-tle
Created July 27, 2022 16:36
Show Gist options
  • Save Kas-tle/3aeddbce1359c202d0b81ac8456dcb2b to your computer and use it in GitHub Desktop.
Save Kas-tle/3aeddbce1359c202d0b81ac8456dcb2b to your computer and use it in GitHub Desktop.
Clean path for model
def cleanpath(inp):
inp
| split("/")
| del(.[0:2], .[3])
| .[-1] = (.[-1] | split(".") | del(.[-1]) | reduce .[] as $item (""; . + ($item) + ".") | .[:-1])
| reduce .[] as $item (""; . + ($item) + "/")
| .[:-1]
;
cleanpath(.)
#"./assets/mega/models/custom/item/test.alpha.json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment