Fixed odm loop error

This commit is contained in:
bender
2023-01-26 22:00:41 -05:00
parent 572341c431
commit 1d58b6f50f
4 changed files with 22 additions and 41 deletions
+13 -23
View File
@@ -1,24 +1,16 @@
#This officially works for the full ODM extraction as of 1/21/23 at 9:54pm
# Define the directories
source config.env
input_folder=$queue
output_folder=$annex
folder=$queue
annex=$annex
shopt -s nullglob
if [ -z "$(find $input_folder -type f -name '*.odm')" ]; then
echo "No .odm files found in $input_folder, exiting."
exit 0
fi
# Open ODM's in temporary directory and export contents
for file in $input_folder/*.odm
for file in $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 "folder path: $folder"
echo "temp_dir path: $temp_dir"
while true; do
@@ -33,17 +25,15 @@ do
echo "downloaded_folder: $downloaded_folder"
# Move the downloaded folder to the destination
mv "$downloaded_folder" "$output_folder"
mv "$downloaded_folder" "$annex"
# 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
#Move the .odm.metadata to the downloaded folder
metadata_file=$(find "$folder" -name "*.odm.metadata")
mv "$metadata_file" "$annex/$(basename "$downloaded_folder")"
rm -rf "$temp_dir"
done
done
rm $queue/*.odm
rm $queue/*.odm.license