Adds media-import and updates README
This commit is contained in:
parent
139b28a369
commit
c3ea98c35d
25
README.md
25
README.md
@ -19,6 +19,11 @@ Drupal2WP Toolkit provides an extensible command-line and plugin-based bridge be
|
||||
- Top-level categories are also **sortable**
|
||||
- Category filters available directly in admin for Pages
|
||||
|
||||
- **Standalone Media Import Tool**
|
||||
- Batch import media from local directories into WordPress
|
||||
- Recursively processes images, documents, and audio files
|
||||
- Supports test mode for dry-run validation
|
||||
|
||||
- **WP-CLI Utilities**
|
||||
- Run `wp drupal2wp_toolkit --help` to learn about Drupal content porting
|
||||
- Easily convert migrated Pages into **Posts**, retaining taxonomy mapping
|
||||
@ -76,6 +81,26 @@ DRUPAL_DB_HOST=your_drupal_db_host
|
||||
wp drupal2wp_toolkit --type=story,hidden_content,vidcast,news_article,resources
|
||||
```
|
||||
|
||||
## 📷 Media Import Tool
|
||||
|
||||
Standalone bash script for importing media files into WordPress.
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
# Full import from sites/ directory
|
||||
./media-import
|
||||
|
||||
# Test mode (first 10 files only)
|
||||
./media-import --test
|
||||
```
|
||||
|
||||
### Requirements
|
||||
- WP-CLI installed and accessible
|
||||
- WordPress path: `/var/www/html` (hardcoded in script)
|
||||
- Run as web server user or use `--allow-root`
|
||||
- Source files in `sites/` subdirectory (relative to script location)
|
||||
|
||||
## 🙌 Credits
|
||||
Contributions and feedback welcome, For contributions, reach out to @bike — this is a toolkit built for extensibility.
|
||||
|
||||
|
||||
37
media-import
Executable file
37
media-import
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Imports media recursively from any directory to wordpress media
|
||||
|
||||
BASE_DIR="sites"
|
||||
TEST_MODE=false
|
||||
|
||||
# Check for --test flag
|
||||
if [[ "$1" == "--test" ]]; then
|
||||
TEST_MODE=true
|
||||
echo "Running in TEST mode (only first 10 files)..."
|
||||
else
|
||||
echo "Running full import..."
|
||||
fi
|
||||
|
||||
# Build the list of files sorted by modification time (newest first)
|
||||
FILES=$(find "$BASE_DIR" -type f \( \
|
||||
-iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.gif" \
|
||||
-o -iname "*.ico" -o -iname "*.doc" -o -iname "*.docx" -o -iname "*.pdf" \
|
||||
-o -iname "*.txt" -o -iname "*.psd" -o -iname "*.tif" -o -iname "*.mp3" \
|
||||
\) -print | xargs ls -1tr)
|
||||
|
||||
# Limit to 10 files if in test mode
|
||||
if $TEST_MODE; then
|
||||
FILES=$(echo "$FILES" | head -n 10)
|
||||
fi
|
||||
|
||||
# Loop through the files
|
||||
echo "$FILES" | while read file; do
|
||||
folder=$(dirname "$file" | sed "s|$BASE_DIR||" | sed 's|^/||')
|
||||
|
||||
echo "Importing $file (folder: $folder)"
|
||||
|
||||
wp media import "$file" \
|
||||
--title="Drupal Import: $(basename "$file") ($(dirname "$file"))" \
|
||||
--path=/var/www/html --allow-root
|
||||
done
|
||||
Loading…
x
Reference in New Issue
Block a user