Last active
January 4, 2018 02:44
-
-
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
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
#/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