Changing files URL's in mass

in Download Manager Free

Viewing 17 posts - 1 through 17 (of 17 total)
Feb 8, 2017 at 11:43 am
#53432
Participant
renzukoken
OP

Hi everyone,

I have a big issue actually, as i don’t want to modify URLs of each download 1 by 1 after changing my server (new domain name)
I tryied editing the database and replace each http://…. by the new one using notepad++ but when importing the database, all fields in attached files get empty.
Is anyone have an idea how to massively replace a part of the attached files URLs after changing server?

Thank you very much.

Feb 9, 2017 at 10:33 am
#53522
Participant
renzukoken
OP

Any moderator available to answer? i searched the addon list without finding anything usefull

Feb 10, 2017 at 11:04 am
#53567
Keymaster
Shahjada
Staff

Sorry, not clear, download URLs are not static, they are dynamically generated and if you move content to another domain , link automatically use the new domain.

Feb 10, 2017 at 2:24 pm
#53573
Participant
renzukoken
OP

I mean each time you add a package, for the attached file, I add an URL for the file to download (on an external server, i don’t use the “upload” function), this URL is set by me.

now all my packages have a URL http://ns32……… but i’m moving all my files to a server named http://ns42….. (still an external server, not the one where WordPress is set)
so all my downloads will not work, i can actually go inside each packages 1 by 1 to update the link to the new server, but doing than more than 3000 times is not what i want.

I tryied to modify those packages link directly into the database, but when i do that, when i edit a package, attached file URL is empty.

What are my solutions?

Feb 13, 2017 at 12:13 pm
#53655
Participant
renzukoken
OP

Hope there is lol, would be hell annoying to update each package. Still trying to find a solution

Feb 13, 2017 at 11:13 pm
#53679
Keymaster
Shahjada
Staff

I see, it will require to write some code, you may try using:

global $wpdb;
$data = $wpdb->get_results( "select * from {$wpdb->prefix}postmeta where mey_key='__wpdm_files'" );
foreach($data as $d){
$newurl = array();
$oldurl = maybe_unserialize($d->meta_value);
foreach($oldurl as $id ► $url){
$newurl[$id] = str_replace("ns32", "ns42",$url);
}
update_post_meta($d->post_id, '__wpdm_files', $newurl);
}
Feb 15, 2017 at 5:43 pm
#53752
Participant
renzukoken
OP

Thanks, will try that and keep you posted 🙂

Jul 1, 2017 at 2:37 pm
#59853
Member
savvasha

Hello there,

I am in the same situation. Does the proposed code worked for you @Renzukoken ??

Thanks!

Jul 1, 2017 at 3:06 pm
#59854
Participant
renzukoken
OP

Hi, I actually managed to un-hack my server so didn’t had to use this script yet (i kept it on a safe place to try as soon as i change server)
But i’ll be very happy to hear about it if someone tries it ^^

Jul 1, 2017 at 3:18 pm
#59857
Member
savvasha

I am not hacked but I am in the process to move from a shared hosting to a VPS one. So all of my internal paths of my files should be changed!

I will keep you updated of how will go 🙂

My first try was to just do an UPDATE through the phpmyadmin, with a total failure. Then I realize that the data ara actually serialized…

Jul 1, 2017 at 3:51 pm
#59858
Member
savvasha

It works perfect for 5500+ files!!!

Thanks Shaon!

Jul 1, 2017 at 4:10 pm
#59859
Participant
renzukoken
OP

awsome news 🙂 you just copy past the code into the SQL request of phpmyadmin? or just in a PHP script you run from your webpage

Jul 1, 2017 at 8:40 pm
#59868
Member
savvasha

It is a PHP code. Not SQL. I just created a page template with the code inside and run it once!

Jul 3, 2017 at 12:52 pm
#59899
Participant
renzukoken
OP

thanks a lot

Oct 27, 2017 at 9:17 am
#64929
Participant
renzukoken
OP

Hi

Sorry to open this old topic, but now changing to a soyoustart server, i decided to follow the steps from this topic to change the files path

From the previous comments look like it woks well, badly, got no clue where to put this code, can anyone guide me for this part?

just tried by copying paste on a template page without result :

Code

Thanks 😉

PS : Can’t it be replaced by an SQL request to do the same thing?

Oct 27, 2017 at 2:27 pm
#64942
Member
savvasha

You can not use plain SQL request because the data are serialized!

Just create an empty Page Template, put the code in with the correct modifications for your case. Then create a Test Page using the Page Template you created just before. And run this page ONCE!

You can add some “echo”s just to debug it.

Oct 28, 2017 at 10:29 am
#64959
Participant
renzukoken
OP

Found the issue 🙂

It was a simple mistake, there is mey_key in the script, a T is missing : meta_key

In the end i created a simple php file at the root of the serveur with inside

include_once('wp-load.php' );
mysql connect etc...

then the script with the missing letter T

And all works perfectly ^^ thanks

Viewing 17 posts - 1 through 17 (of 17 total)

The topic "Changing files URL's in mass" is closed to new replies.