Created
April 24, 2015 20:03
-
-
Save slowkow/f5b1e76fb6c4db7dcf31 to your computer and use it in GitHub Desktop.
Make a manifest file for Aspera.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# make_aspera_manifest.sh | |
# Kamil Slowikowski | |
# | |
# Make a manifest file suitable for Aspera. | |
# | |
# Example | |
# ------- | |
# | |
# Suppose we wish to send a folder full of files called "data". We want | |
# to maintain the directory structure of our files inside "data". | |
# | |
# tree /path/to/data | |
# /path/to/data | |
# |-- file1.txt | |
# |-- file2.txt | |
# `-- folder1 | |
# `-- file3.txt | |
# | |
# 1 directory, 3 files | |
# | |
# The manifest file should contain the full path to each file in the first | |
# column. The second column should contain the partial path, omitting | |
# directories that are specific to the machine you are using. | |
# | |
# Invoke this script like so: | |
# | |
# ./make_aspera_manifest.sh /path/to/data /path/to/ > manifest.txt | |
# | |
# The resulting manifest.txt file will look like this: | |
# | |
# /path/to/data/file1.txt data/file1.txt | |
# /path/to/data/file2.txt data/file2.txt | |
# /path/to/data/folder1/file3.txt data/folder1/file3.txt | |
# | |
# Notice that the second column does not contain the string "/path/to/". | |
# | |
# See Also | |
# -------- | |
# | |
# http://download.asperasoft.com/download/docs/ascp/3.0/html/index.html | |
if [[ ! -d "$1" || "$2" == "" ]]; then | |
echo "usage: $0 DIR TRIM" | |
exit 1 | |
fi | |
DIR="$1" | |
TRIM="$2" | |
find "$DIR" -type f \ | |
| perl -ne 'chomp; print "$_\t"; s{'$TRIM'}{}; s{/[^/]+$}{}; print "$_\n"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment