Kevin's Worklog

Documenting the Daily Stream

Migrating Select Pairtree Files

The Pairtree file structure is a hiearchical structure into which files can be put. In my case I store different types of files in it: JPEGs, JP2, TIFFs, etc. I have a case for which I need to copy all the files of one type out of the existing structure and into a new Pairtree structure in a different location.

Here is a Bash script I whipped up to do that:

#! /bin/bash

find "${1}" -type f -name "*.jp2" -print0 | while IFS= read -r -d $'\0' LINE; do
  echo "cp ${1}${PATH} ${2}${PATH}"

It takes a “from” directory and a “to” directory as arguments. Right now it’s hard wired for JP2s but that could be a third argument to the script.