diff --git a/.local/bin/aofiledl b/.local/bin/aofiledl new file mode 100755 index 0000000..b511d16 --- /dev/null +++ b/.local/bin/aofiledl @@ -0,0 +1,39 @@ +#!/bin/bash + +# Check if a URL is provided +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +url="$1" + +# Extract the folder name from the URL +folder_name=$(basename "$url" | sed 's/%20/ /g' | sed 's/\/$//') + +if [[ "$url" != */ ]]; then + # If the URL ends with a single slash, we keep it as is + url="$url/" +fi + +wget --no-parent --recursive -P "output" "$url" + +# Find the downloaded folder in the output directory +downloaded_folder_path=$(find output -type d -name "$folder_name" -print -quit) + + +# Check if the folder was found +if [ -z "$downloaded_folder_path" ]; then + echo "Folder '$folder_name' not found in 'output'." + exit 1 +fi + +find "$downloaded_folder_path" -type f -name "*.htm*" -exec rm -f {} + + +# Move the downloaded folder to the current directory +mv "$downloaded_folder_path" . + +# Remove the output directory recursively +rm -rf output + +echo "Downloaded '$folder_name'." \ No newline at end of file