String Find and Replace in MySQL

When creating resource links to assets in our CMS a couple of users had inadvertently linked to the ‘._Filename.doc’ file created by OSX, instead of the intended ‘Filename.doc – on just under 300 files.

Running a quick query to return all the affected resources I used the REPLACE funtion in MYSQL to set all the asset values again (minus the ‘._’)

set value = REPLACE(value, '/._', '/')
where value like '%/._%'

Leave a Reply

Your email address will not be published. Required fields are marked *