This guide is intended for unix based OS, the script provided won't work on Windows terminal. If you'd like to contribute to improve and complete this guide, please write to us on the chat.
The Export module allows you to download a ZIP archive that contains a JSON file for each document published in Prismic. Some users need to have human readable filename to ease their workflow. You can easily rename JSON files by using any of the data contained in the document (like its UID or its title).
For this script to work, you need to install "json" (a CLI tool to work with JSON):
npm install -g json
This example will go through the JSON files, and rename them with the value of the "uid" field:
- Create a file called
script_rename.shin the folder where you want to rename JSON files, paste this script in it:
for filename in ./*.json; do
newname=$(json -f $filename uid)
mv "$filename" "$newname$filetype"
Note that you can replace
uid with any field key you'd like to use to rename the file.
In your terminal, go to the folder where you want to rename files:
- allow execution of this script
chmod +x script_rename.sh
- run it