https://torbjornzetterlund.com/wp-content/uploads/2014/05/wordpress-logo-notext-rgb-960x600_c.png

Migrating images url from one web platform to another webplatform


I recently run in to an issue with migrating image url’s from a .NET web platform to WordPress. The issue was that all the images was storied in one folder on the .NET platform content server, and the requirement for the migration of the images was only to move one category to WordPress.

The way the .NET web platform referenced the images used on webpages, was by GUID, that was stored in the database together with the URL path name.

To give an example on the following URL – http://www.torbjornzetterlund.com/cycling/victories/photos/IMG_20150626_123403.jpg

When url is requested, the .NET web platform strips out the “cycling/victories/photos/IMG_20150626_123403.jpg” – search the database for the match – when match is found the .NET platform uses the GUID to find the image file on the content server.

What I did was to export from the database all the URL path, add the domain name in front and I got a list of URL with images to move to WordPress. To actually move the files, I had to use the server command line to copy the files from the .NET web platform by requesting the file by url using the command curl, here is what i did and it worked out great for me.

Login to your server, navigate to the folder of your wordpress installation were you want the images copied to and use the following commands to do the copying.

cat <<URLS | xargs -P5 -n1 curl -O
> http://torbjornzetterlund.com/cycling/victories/photos/IMG_20150626_123403.jpg
> http://torbjornzetterlund.com/cycling/victories/photos/IMG_0389.jpg
> http://torbjornzetterlund.com/cycling/victories/photos/IMG_20150620_141000.jpg
> http://torbjornzetterlund.com/cycling/victories/photos/IMG_0278.jpg
> http://torbjornzetterlund.com/cycling/victories/photos/IMG_0363.jpg
>URLS

This will copy the images from the .NET web platform to your WordPress folder, xargs -P5 let you have 5 concurrent downloads running at the same time.

You could also dump your urls into a txt file and use the wget command

wget -i urls.txt

The last step is to make the files available in the media manager in WordPress – you can read how to do add to server in WordPress.

For me this worked great for what I need to do, simple copy of the files, I tested this with over a 100 urls and it worked fine. I hope this is useful information for others, like to comment just look down and provide your feedback.

Menu