Skip to content

Instantly share code, notes, and snippets.

@simesy
Last active December 3, 2019 04:38
Show Gist options
  • Save simesy/d66c49d43ae15603c7d9317973d14f6a to your computer and use it in GitHub Desktop.
Save simesy/d66c49d43ae15603c7d9317973d14f6a to your computer and use it in GitHub Desktop.
notes for replacing a media with files
# Reges for finding drupal entities.
/<drupal-entity.*?data-entity-uuid="(.{36})">\s*?<\/drupal-entity>/
# raw data for command linking UUID with file
ahoy drush sqlq "SELECT m.mid as mid, m.uuid as uuid, mfd.status, f.fid as fid, f.filemime, f.filesize, f.filename, f.uri, mfd.name FROM media m INNER JOIN media_field_data mfd ON m.mid = mfd.mid INNER JOIN media__field_media_file mff ON m.mid = mff.entity_id INNER JOIN file_managed f ON mff.field_media_file_target_id = f.fid;"
# rough command
gsed -i -e s/PLACEHOLDER_12312312-1231-1231-1231-123123123123_PLACEHOLDER/"[<a href=\\\\\"\/sites\/default\/files\/SOMEFILE.pdf\\\\\">PDF: 8818 KB<\/a>]"/g ~/Backups/iwork.sql && echo "12312312-1231-1231-1231-123123123123"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment