Skip to content

Instantly share code, notes, and snippets.

@Atlante45
Last active January 4, 2018 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Atlante45/7bbc0c112637843a4069018fd05ec392 to your computer and use it in GitHub Desktop.
Save Atlante45/7bbc0c112637843a4069018fd05ec392 to your computer and use it in GitHub Desktop.
small script that processes a large amount of files to add to an Asset Server
#/bin/sh
input="$(dirname $0)/input"
output="$(dirname $0)/output"
if [ ! -d "$input" ]; then
echo "Missing input folder: $input";
exit;
fi
if [ ! -d "$output" ]; then
echo "Missing output folder: $output";
exit;
fi
files=$(find $input -type f);
mkdir "$output/files";
touch "$output/mapping.txt";
> "$output/mapping.txt"; # clear file if already exists
echo "$files" | while read f
do
path=${f:${#input}};
hash=$(cat "$f" | shasum -a 256 | cut -d " " -f 1);
echo "File: $f\nPath: $path\nHash: $hash";
cat "$f" > "$output/files/$hash";
echo "\"$path\": \"$hash\"," >> "$output/mapping.txt";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment