Kodi Community Forum

Full Version: Script for file management (Ubuntu)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need some help creating a script that would run nightly.  I have a HDHomeRun and the HDHomeRun DVR running on a homemade Ubuntu server with raid storage.  The OS runs on an SSD card and I have the HDHomeRun recording to the SSD to avoid performance issues with the raid drives, however it fills up fast.  The HDHomeRun folder is also a samba share and is a Kodi library.  What I want to do is run a script that would move recorded shows to the raid drive and replace the file with a link to the moved file.  This way, the HDHomeRun would still see the recorded episodes and Kodi can still access the recordings via the Samba share.
I haven't tested this, but something like...



for RECORDING in "${DIR_RECORD}"/*; do
    if [ ! -L "${RECORDING}" ]; then
       # make sure to ignore file if currently being written to
       lsof "${RECORDING}"
       if [ $? -eq 1 ]; then
          RECORDED=`basename "${RECORDING}"`
          mv "${RECORDING}" "${DIR_ARCHIVE}/"
          ln -s "${DIR_ARCHIVE}/${RECORDED}" "${RECORDING}"