Search Replace in MySQL: remove directory structure but keep filename -


i changing directory structures in drupal installation , need remove path data except file name itself.

so basic structure is:

+-------------+--------------+---------+-----------+-------------+----------+-------+----------------------------------------------------------------------------------+-----------------------+ | entity_type | bundle       | deleted | entity_id | revision_id | language | delta | field_filename_value                                                             | field_filename_format | +-------------+--------------+---------+-----------+-------------+----------+-------+----------------------------------------------------------------------------------+-----------------------+ 

the filename stored in field_filename_value. here's sample record:

+-------------+--------------+---------+-----------+-------------+----------+-------+----------------------------------------------------------------------------------+-----------------------+ | entity_type | bundle       | deleted | entity_id | revision_id | language | delta | field_filename_value                                                             | field_filename_format | +-------------+--------------+---------+-----------+-------------+----------+-------+----------------------------------------------------------------------------------+-----------------------+ | node        | presentation |       0 |        11 |          11 | und      |     0 | /really long path name/with lots of words/167 clarence ashley - coo coo bird.mp3 | null                  | +-------------+--------------+---------+-----------+-------------+----------+-------+----------------------------------------------------------------------------------+-----------------------+ 

that ridiculous filename value needs changed from:

  /really long path name/with lots of words/167 clarence ashley - coo coo bird.mp3 

to this:

 167 clarence ashley - coo coo bird.mp3 

setting aside bad practice of using spaces in file/directory names, how correct this? possible using mysql features alone?

as added challenge, files may more 2 directories deep.

use substring_index

select substring_index('http://www.example.com/dev/archive/examples/test.htm','/',-1)

(both above

mysql string last index of

how use easy, explain, select last index of / , substring function cut off left of it


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -