scriptardo para descargar archivos del atroon facil

This commit is contained in:
simio 2025-06-09 08:06:55 -03:00
parent b90574f684
commit 203a251932

39
.local/bin/aofiledl Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
# Check if a URL is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <url>"
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'."