Imagine you have hundred thousands of videos and graphics sorted into folders and subfolders and want to move these data into Final Cut Server (FCSvr).
If you create a FCSvr device and copy all these assets onto this device while preserving the folder structure you are used to, and let FCSvr scan this device, then each asset will store its relative path on this device in its metadata.
If e.g. a media file has the file path /Volumes/MyBigStorage/MigratedFiles/cars/german/bmw/Z4_in_summer_with_blue_sky.jpg, then both the file path elements and the file name hold valuable asset metadata which you might want to use in your FCSvr DB.
If your FCSvr device has the file path /Volumes/MyBigStorage/MigratedFiles, then the relative path (called Location) stored in the asset's metadata will be /cars/german/bmw, while the file name will be Z4_in_summer_with_blue_sky.jpg.
If now you search for
cars bmw
FCSvr won't find this asset. You need to search for cars/german/bmw to find this asset, as FCSvr doesn't support finding a single string when you search for multiple parts of it.
Your users expect to find the asset using the search string "cars bmw", so we need to fix this. This article explains how to do this.
So what are we going to do?
Whenever a file is added to the FCSvr database, we want FCSvr to take the location and the filename, extract all valuable metadata as individual strings and add them to the metadata field "Keywords". In our example, we would translate
/Volumes/MyBigStorage/MigratedFiles/cars/german/bmw/Z4_in_summer_with_blue_sky.jpg
into
cars german bmw Z4 in summer with blue sky jpg
and add this string to the Keywords field. We need to make sure that we don't overwrite existing keywords.
To do this, please follow these steps:
- On the FCSvr machine, open the Terminal and get root permissions. Now type:
- Now copy this text into /usr/local/path2key/bin/path:
...or download this file instead and extract it. This script will later extract the metadata from the file path and the filename. It replaces . / - _ – against whitespaces.#!/bin/bash # ################################################### # path2key, copyright 2011 by www.andre-aulich.de # # This script accepts the asset id of a FCSvr # # asset as its only parameter. It then extracts # # the file path and adds all parts of the path as # # keywords to the asset's FCSvr metadata. # ################################################### # Define our variables and set up logging. PATH="/Library/Application Support/Final Cut Server/Final Cut Server.bundle/Contents/MacOS/":$PATH LOGFILE="/usr/local/path2key/logs/path2key.log" ASSETID="$1" echo "$(date)" >> "${LOGFILE}" if [[ "$1" == "" ]]; then echo "No asset ID given. Stopping." >> "${LOGFILE}" echo "---------------------------------------------------------" >> "${LOGFILE}" exit 0 fi echo "Processing file path of asset ${ASSETID}." >> "${LOGFILE}" PATHKEYWORDS="$(fcsvr_client getmd /asset/${ASSETID} | grep "PA_MD_CUST_FILENAME:|CUST_LOCATION:" | sed -e 's/CUST_LOCATION://' -e 's/PA_MD_CUST_FILENAME://' -e 's/^[ t]*//' -e 's/^///' -e 's/[./-]/ /g' -e 's/_/ /g' | awk '{printf("%s", $0 (NR==1 ? " " : " "))}')" echo "Keywords extracted from file path are:" >> "${LOGFILE}" echo "${PATHKEYWORDS}" >> "${LOGFILE}" FCSVRKEYWORDS="$(fcsvr_client getmd /asset/${ASSETID} | grep "CUST_KEYWORDS" | sed -e 's/CUST_KEYWORDS://' -e 's/^[ t]*//')" echo "Keywords extracted from FCSvr are:" >> "${LOGFILE}" echo "${FCSVRKEYWORDS}" >> "${LOGFILE}" COMPLETEKEYWORDS="$(echo ${FCSVRKEYWORDS} ${PATHKEYWORDS})" echo "Complete keywords are:" >> "${LOGFILE}" echo "${COMPLETEKEYWORDS}" >> "${LOGFILE}" sudo fcsvr_client setmd /asset/"${ASSETID}" CUST_KEYWORDS="${COMPLETEKEYWORDS}" >> "${LOGFILE}" echo "---------------------------------------------------------" >> "${LOGFILE}" - Now open the FCSvr Administration window and create a new response using these data:
- Response Action: Run an external script or command
- Name: path2key
- Command path: /usr/local/path2key/bin/path2key
- Command Parameters: [Asset ID]
- Create a Subscription using these data:
- Subscribe to: Asset
- Name: path2key
- Enabled: needs to be activated
- Event Type Filter: Created
- Response List: path2key
- To make sure our script can write to the FCSvr database, we need to add this line to /etc/sudoers/:
ALL ALL = NOPASSWD: /Library/Application Support/Final Cut Server/Final Cut Server.bundle/Contents/MacOS/fcsvr_client - You might need to restart the FCSvr client interface, and probably the FCSvr server, too.
mkdir -p /usr/local/path2key/bin
mkdir -p /usr/local/path2key/logs
cd /usr/local/path2key/bin
touch path2key
chmod +x path2key
touch ../logs/path2key.log
chmod 777 ../logs/path2key.log
If now you upload some files to FCSvr, please look at their Keywords metadata field. The file path and file name elements should be added to the list of keywords, and now your users will be able to search for
bmw cars
to find your asset. Hope this helps.
André


Thanks André, this is nice. It also provides a solution to a current conversation on Apple Discussions, Archiving in H264 while keeping folders/file creation date.
If I were to deploy this for a client I would customize it even further, if they had a lot of content that was well organized and interrelated.
For example, instead of dumping all the metadata together into a single keywords field, I'd map them all to custom metadata fields:
- Vehicle Category: cars
- Nationality: german
- Manufacturer: bmw
- Vehicle: Z4
- Description: in summer with blue sky
Then you can find items more precisely, set up smart searches, create metadata subscriptions and automations, and just in general benefit from the fact you are using a relational database instead of just a big text field.