Sunday, August 15, 2010

download filenames with spaces

Based on a visitor email to webmaster, checked out a download problem. Found that there are many Radio Sai Bhajan Classrooms which have download-file-name with spaces on the database.

Did an update to the database. Basically just
Update `files_table` SET `downloadfileName` = REPLACE(downloadfilename, ' ' , '_' ) where `downloadfilename` like '%Clasr%'

But because our database has some strange requirements on the server, it actually had to be written as

Update `files_table` SET `downloadfileName` = REPLACE(downloadfilename, CONVERT(_utf8 ' ' USING latin1) , CONVERT(_utf8 '_' USING latin1) ) where `downloadfilename` like CONVERT(_utf8 '%Clasr%' USING latin1) COLLATE latin1_swedish_ci

It updated 40 odd entries. I also then replaced Clasroom with Classroom in download file names, and later renamed in these dl.radiosai.org using lots of
mv Source.mp3 Destination.mp3
statements in a text file.

Doing this for all entries, using
where `downloadfilename` like CONVERT(_utf8 '%' USING latin1) COLLATE latin1_swedish_ci
it said updated 4 more entries.

Then updated our local database also, and again replaced all download_File_names with spaces with underscores for all entries, and Clasroom with Classroom.

No comments:

Post a Comment