From 203a251932c16b669304c1318f45ffc260038da2 Mon Sep 17 00:00:00 2001 From: gor_down Date: Mon, 9 Jun 2025 08:06:55 -0300 Subject: [PATCH] scriptardo para descargar archivos del atroon facil --- .local/bin/aofiledl | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 .local/bin/aofiledl 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