Download Attachment
Documentsdownload-attachmentDownload Attachment is an Agent Skill for documents published in the heyitsnoah/claudesidian repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Download files from URLs to the Obsidian attachments folder and organize them with descriptive names. Use when the user provides URLs to download, asks to save files from the web, or wants to add web content as attachments.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/heyitsnoah/claudesidian/blob/HEAD/.agents/skills/download-attachment/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/download-attachment, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
download-attachment
Download files from URLs to attachments folder and organize them with descriptive names.
Usage
/download-attachment <url1> [url2] [url3...]
Examples
/download-attachment https://example.com/document.pdf
/download-attachment https://site.com/image.png https://site.com/report.pdf
Implementation
You are tasked with downloading files from URLs and organizing them in the Obsidian vault attachments folder.
Step 1: Parse and Validate URLs
Extract the URL(s) from the user's input. Handle multiple URLs if provided.
- Validate URL scheme: Only allow http:// or https:// URLs
- Reject invalid URLs: file://, ftp://, or malformed URLs
- Example validation:
if [[ ! "$url" =~ ^https?:// ]]; then
echo "Error: Only HTTP/HTTPS URLs are allowed"
exit 1
fi
Step 2: Download Files
For each URL:
# Sanitize filename to prevent path traversal
# Remove ../ and other dangerous characters
filename=$(basename "$url" | sed 's/[^a-zA-Z0-9._-]/_/g')
# Use wget or curl to download with timeout
wget --timeout=30 -O "05_Attachments/$filename" "$url"
# or
curl --max-time 30 -L "$url" -o "05_Attachments/$filename"
Step 3: Verify Downloads
Check that files were downloaded successfully:
ls -la "05_Attachments/"
Step 4: Organize Files
After downloading, run the organize-attachments command to rename files with descriptive names:
For PDFs:
- Extract text with
pdftotext - Analyze content for meaningful title
For Images:
- Use
mcp__gemini-vision__analyze_imageormcp__gemini-vision__analyze_multiple - Generate descriptive filename based on content
Step 5: Move to Organized
Move renamed files to 05_Attachments/Organized/ with descriptive names
Step 6: Update Index
Add entries to 05_Attachments/00_Index.md
Step 7: Commit Changes
git add -A
git commit -m "Download and organize attachments from URLs"
git push
Important Notes
-
File Naming:
- Initial download: Use URL filename or generate from URL
- After analysis: Rename with descriptive title
-
Supported Types:
- Images: .png, .jpg, .jpeg, .gif, .webp
- Documents: .pdf, .doc, .docx
- Text: .txt, .md
- Data: .csv, .xlsx
-
Error Handling:
- Check if URL is accessible
- Verify file downloaded correctly
- Handle download failures gracefully
-
Organization:
- Downloaded files go to
05_Attachments/ - After renaming, move to
05_Attachments/Organized/ - Update links across vault if needed
- Downloaded files go to
Workflow
- Download file(s) from provided URL(s)
- Identify file type and analyze content
- Generate descriptive filename
- Move to Organized folder
- Update index and references
- Commit and push changes
Tips
- For multiple URLs, process them in batch for efficiency
- Use Gemini Vision for batch image analysis (up to 3 at once)
- Extract meaningful context from PDFs before renaming
- Preserve original file extensions
- Keep filenames concise but descriptive (max 60 chars)