Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Bulk Import into Media Library View modes: 
User avatar
Member
Member
robert-tailor.co - 9/17/2012 4:57:49 PM
   
Bulk Import into Media Library
Hi,

I have thousands of images in hundreds of subdirectories that I need to import into the Media Library.

I've copied the relevant contents to the appropriate directory, and the files are all there waiting to be imported.

How can I do a bulk import on all the items? I can't see an option to recurse down through the directories and perform a bulk import.

Thanks!

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 9/17/2012 5:08:59 PM
   
RE:Bulk Import into Media Library
I don't think you can do an automated import of all of the files. You can put your files into the Media folder under the appropriate media gallery and go to the Media Gallery in CMS Desk and you will see them there with a "warning" icon next to them. You can use the checkboxes to select the files and use the action dropdown to choose "import" and click "OK". Even when you do this, you are prompted for each file to add some additional information or just click Import.

This hasn't changed for V7.

User avatar
Member
Member
robert-tailor.co - 9/17/2012 5:26:00 PM
   
RE:Bulk Import into Media Library
Jiveabillion wrote: I don't think you can do an automated import of all of the files. You can put your files into the Media folder under the appropriate media gallery and go to the Media Gallery in CMS Desk and you will see them there with a "warning" icon next to them. You can use the checkboxes to select the files and use the action dropdown to choose "import" and click "OK". Even when you do this, you are prompted for each file to add some additional information or just click Import.

This hasn't changed for V7.

That...sucks.

Is there an alternative to spending the next 100 hours of my life going through and clicking into every single individual folder and clicking 'import'?

User avatar
Member
Member
robert-tailor.co - 9/17/2012 7:43:43 PM
   
RE:Bulk Import into Media Library
robert-tailor.co wrote: Is there an alternative to spending the next 100 hours of my life going through and clicking into every single individual folder and clicking 'import'?

So I wrote an importer instead, by combining the info provided here:

http://msdn.microsoft.com/en-us/library/bb513869.aspx

here:

http://devnet.kentico.com/Forums.aspx?forumid=45&threadid=15557

and the CMS API Example (Site Manager -> Support -> API Examples -> Tools -> Media -> Media File -> Create File

Note - the CMS API Example doesn't show you how to import your existing file in to the library. Use the 2nd link to the Forum example for that.

Also note that the importer is very fickle about file paths. Use the dbo.Media_File table for reference and do lots of test runs first!

User avatar
Certified Developer 8
Certified Developer 8
Jiveabillion - 9/18/2012 12:27:35 PM
   
RE:Bulk Import into Media Library
Well yeah, you can do it like that. It's just not a built-in feature :)

User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC.Rochester - 11/13/2012 1:56:06 PM
   
RE:Bulk Import into Media Library
I'm working on something similar, but I need to check if the file is already imported before I import the file. Did you do this, or do you have any idea of a good way to do this? Right now I'm trying to work off of DataRow FileIsNotInDatabase(string fileName) in \CMSModules\MediaLibrary\Controls\MediaLibrary\MediaLibrary.ascx.cs, but it's rather messy.

User avatar
Member
Member
robert-tailor.co - 11/13/2012 2:10:38 PM
   
RE:Bulk Import into Media Library
Gavin_Paolucci-Kleinow-URMC.Rochester wrote: I'm working on something similar, but I need to check if the file is already imported before I import the file. Did you do this, or do you have any idea of a good way to do this? Right now I'm trying to work off of DataRow FileIsNotInDatabase(string fileName) in \CMSModules\MediaLibrary\Controls\MediaLibrary\MediaLibrary.ascx.cs, but it's rather messy.

Try this:

// Add the file data to dbo.Media_File
try
{
MediaFileInfoProvider.ImportMediaFileInfo(mediaFile);
}
catch (Exception)
{
// Ignore the error and carry on
returnString = "<br />COULD NOT IMPORT (ALREADY EXISTS): " + mediaFile.FilePath;
//throw;
}

where 'mediaFile' is the new MediaFileInfo object you're trying to import.

User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC.Rochester - 11/14/2012 9:01:13 AM
   
RE:Bulk Import into Media Library
That does work, but isn't what I'm looking for. I'm hoping to check if the file is imported before trying t import. Any other ideas?

User avatar
Member
Member
robert-tailor.co - 11/14/2012 1:50:37 PM
   
RE:Bulk Import into Media Library
Gavin_Paolucci-Kleinow-URMC.Rochester wrote: That does work, but isn't what I'm looking for. I'm hoping to check if the file is imported before trying t import. Any other ideas?

You could use the example given in the API examples in "Site Manager -> Support -> API Examples -> Tools -> Media -> Media File -> Get and update file" as a basis:

// Get the media file
MediaFileInfo foundFile = MediaFileInfoProvider.GetMediaFileInfo(CMSContext.CurrentSiteName, "MyNewFolder/MyNewFile.gif", null);
if (foundFile != null)
{
// Stop! File already exists in library!
}
else
{
// File not found in library. Proceed with import.
}

User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC.Rochester - 11/27/2012 1:05:17 PM
   
RE:Bulk Import into Media Library
Robert,
Thanks! That is exactly what I was looking for.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 11/19/2012 12:49:47 AM
   
RE:Bulk Import into Media Library
Hi,

does the answer from Robert meets your needs?

Best regards,
Martin Danko

User avatar
Member
Member
Gavin_Paolucci-Kleinow-URMC.Rochester - 11/27/2012 1:06:03 PM
   
RE:Bulk Import into Media Library
Martin,
Yes it does. Thanks!