This automation script is solve a certain WordPress SEO problem..... When a WordPress site goes live, one of the tasks for SEO is to rename all images in the media library and add description text, alt text and captions for all images.... This automated script will visit any WordPress website, Login go to media library and rename each and every image correctly
git clone https://github.com/root-account/python_selenium_automation.gitpython_selenium_automation is an automation script designed to streamline WordPress SEO optimization tasks. It automates the process of renaming images in the WordPress media library and adding metadata including description text, alt text, and captions. The script logs into WordPress sites, navigates to the media library, and systematically updates each image with proper SEO attributes. This tool is particularly useful when launching WordPress websites that require bulk image optimization for search engine visibility.
["Install required dependencies: `pip install selenium webdriver-manager`","Replace [WORDPRESS_URL], [USERNAME], [PASSWORD], and metadata templates in the script with your actual WordPress credentials and SEO naming conventions","Run the script: `python wordpress_seo_automation.py`","Monitor the console output for progress and any errors (script will continue if individual images fail)","Verify changes in WordPress media library after completion. For large libraries, consider running during off-peak hours"]
Bulk rename and optimize images in WordPress media library after site launch
Add alt text and descriptions to multiple images simultaneously for SEO compliance
Automate caption generation and metadata assignment for WordPress image assets
Streamline on-page SEO preparation for newly launched WordPress websites
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/root-account/python_selenium_automationCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Write a Python script using Selenium to automate the process of renaming WordPress media library images and adding SEO metadata (description, alt text, and captions). The script should: 1) Navigate to [WORDPRESS_URL], 2) Log in with credentials [USERNAME] and [PASSWORD], 3) Access the media library, 4) For each image, rename it to [NEW_FILENAME] and add [DESCRIPTION], [ALT_TEXT], and [CAPTION] based on [NAMING_CONVENTION], 5) Save changes. Include error handling for login failures and image processing issues.
```python
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
# Initialize Chrome WebDriver
driver = webdriver.Chrome()
# Navigate to WordPress login page
wordpress_url = "https://yourwordpresssite.com/wp-admin"
driver.get(wordpress_url)
# Login credentials
username = "your_admin_username"
password = "your_secure_password"
# Fill login form
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "user_login"))).send_keys(username)
driver.find_element(By.ID, "user_pass").send_keys(password)
driver.find_element(By.ID, "wp-submit").click()
# Wait for dashboard to load
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "menu-dashboard")))
# Navigate to Media Library
media_link = driver.find_element(By.ID, "menu-media")
media_link.click()
media_submenu = driver.find_element(By.ID, "submenu-media-library")
media_submenu.click()
# Wait for media library to load
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "media-grid")))
# Process each image in the library
images = driver.find_elements(By.CSS_SELECTOR, ".attachment")
for i, image in enumerate(images):
try:
# Click on the image to open edit modal
image.click()
time.sleep(2)
# Rename image (example: add "-seo" suffix)
current_title = driver.find_element(By.ID, "attachment-title").get_attribute("value")
new_title = f"{current_title}-seo"
driver.find_element(By.ID, "attachment-title").clear()
driver.find_element(By.ID, "attachment-title").send_keys(new_title)
# Add SEO metadata
description = f"Professional {new_title} for WordPress site"
alt_text = f"{new_title} - optimized for search engines"
caption = f"Featured {new_title} in our latest project"
driver.find_element(By.ID, "attachment-description").send_keys(description)
driver.find_element(By.ID, "attachment-alt-text").send_keys(alt_text)
driver.find_element(By.ID, "attachment-caption").send_keys(caption)
# Save changes
save_button = driver.find_element(By.ID, "save-all")
save_button.click()
time.sleep(1)
print(f"Processed image {i+1}/{len(images)}: {new_title}")
except Exception as e:
print(f"Error processing image {i+1}: {str(e)}")
continue
print("SEO metadata update completed!")
driver.quit()
```
This script automates the tedious process of updating WordPress media library images with SEO-optimized metadata. For a site with 50 images, it would typically process each one in about 15-20 seconds, completing the entire library in 12-15 minutes—compared to hours of manual work. The script handles the login process securely, navigates directly to the media library, and systematically updates each image's filename and metadata fields. Error handling ensures that if one image fails (e.g., due to a network hiccup), the script continues with the next one rather than stopping entirely. The naming convention adds "-seo" to each filename and generates descriptive metadata based on the image title, which follows common SEO best practices for WordPress sites.Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan