Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-11-14 17:22:45

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 566
Website

bulk change file-id to file-name in custom-field using MySql

Hi,
I would like to run a query to change the value of a custom field from the file ID to the file name please.
I’m moving all the files from the site server to Google Cloud Storage, and then I will remove the files from the site server.
I’m using a custom field to assign an ID of a file, so I want to change it to the file name please.
Currently if I will delete the files from the site server and from TXP files-tab, then I will just have meaningless ID numbers in my custom-filed and broken links to the files.
Since there are thousands of files, this will be hell to do it manually.

Offline

#2 2019-11-14 17:48:46

etc
Developer
Registered: 2010-11-11
Posts: 3,399
Website

Re: bulk change file-id to file-name in custom-field using MySql

Caution: untested! Assuming file ids are stored in custom_1 field:

UPDATE textpattern
INNER JOIN txp_file ON textpattern.custom_1 = txp_file.id
SET textpattern.custom_1 = txp_file.filename
WHERE textpattern.custom_1 > ''

Offline

#3 2019-11-14 19:11:00

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 566
Website

Re: bulk change file-id to file-name in custom-field using MySql

etc wrote #320090:

Caution: untested! Assuming file ids are stored in custom_1 field:

Works great, thanks a lot 🙌

Offline

Board footer

Powered by FluxBB