1

Can anyone advice on how I can mass update document urls in node body content?

I am in the process of migrating a just over a thousand pages into Drupal using the migrate module.

The pages are successfully migrating but they also have PDF documents uploaded into the body field of a lot of the nodes. Those pdf links are now broken because the pdf documents are uploaded into a migration/intranet/files/ directory as opposed to files.

Using this example, I tried the following directly approach to update a sample body field:

UPDATE field_data_body SET body_value = REPLACE( body_value, '<a href=\"', '<a href=\"/migration/intranet/files/') where entity_id=20916;

My update works but I get the following path as a result:

http://*.*.*.*/intranet/migration/intranet/files/migration/intranet/files//migration/intranet/files///migration/intranet/files/migration/intranet/files/intranet/migration/intranet/filess1_2015_-_iworld_release_6.12.pdf

Instead of: http://*.*.*.*/intranet/migration/intranet/files/s1_2015_-_iworld_release_6.12.pdf

Community
  • 1
  • 1
sisko
  • 9,604
  • 20
  • 67
  • 139

1 Answers1

0

If you currently have src="/files/..." and you want to have src="/migration/intranet/files/..." you should do a search and replace like this

UPDATE field_data_body SET body_value = REPLACE( body_value, '<a href=\"/files/', '<a href=\"/migration/intranet/files/') WHERE entity_id = 20916;
Mike Vranckx
  • 5,557
  • 3
  • 25
  • 28