Add files via upload

This commit is contained in:
bender
2023-01-25 16:35:09 -05:00
committed by GitHub
parent c508a19570
commit c42a6c8a1b
11 changed files with 492 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
#This officially works for the full ODM extraction as of 1/21/23 at 9:54pm
input_folder="/Users/jonas/Documents/SERVER/QUEUE"
output_folder="/Users/jonas/Documents/SERVER/BOOKS/01_ANNEX"
# Open ODM's in temporary directory and export contents
for file in $input_folder/*.odm
do
# Make temp dir in loop so that it clears even if there's any errors
temp_dir=$(mktemp -d)
cd "$temp_dir"
echo "folder path: $input_folder"
echo "temp_dir path: $temp_dir"
while true; do
if ~/.local/bin/overdrive download $file; then
break
fi
sleep 2 # wait for 2 seconds before retrying
done
# Get the name of the downloaded folder
downloaded_folder=$(find "$temp_dir" -type d -mindepth 1 -maxdepth 1 | head -n 1)
echo "downloaded_folder: $downloaded_folder"
# Move the downloaded folder to the destination
mv "$downloaded_folder" "$output_folder"
# Move the .odm.metadata to the downloaded folder
metadata_file=$(find "$input_folder" -name "*.odm.metadata")
mv "$metadata_file" "$output_folder/$(basename "$downloaded_folder")"
# Delete leftover .odm and .odm.license files
odm=$(find "$input_folder" -name "*.odm")
license=$(find "$input_folder" -name "*.odm.license")
rm $odm
rm $license
rm -rf "$temp_dir"
done