Scripting it out would be the best way to go about it. If the file exists though and you use the API to create the MediaInfo and the item exists in the same spot, it will upload and duplicate it.
You should push them to a different folder, then use the media API to create the new media file sourcing from the different folder, that way it won't get the _1, it's annoying i know...
If you need a sample:
// Create a temporary upload path
var uploadPath = AppDomain.CurrentDomain.BaseDirectory.Replace("\\", "/").Trim('/') + "/App_Data/Images_Temp";
if (!Directory.Exists(movePath))
{
CMS.IO.DirectoryHelper.EnsureDiskPath(movePath.Replace("/", "\\"), AppDomain.CurrentDomain.BaseDirectory);
CMS.IO.DirectoryHelper.CreateDirectory(movePath.Replace("/", "\\"));
}
if (!Directory.Exists(movePath))
{
throw new Exception("Could not create temp directory, ensure your app pool has proper permissions.");
}
// Download file there, you can skip this if you are copying the files to a folder instead
using (var client = new WebClient())
{
try
{
client.DownloadFile(MediaUrl, uploadPath);
}
catch (WebException wex)
{
if (((HttpWebResponse)wex.Response).StatusCode == HttpStatusCode.NotFound)
{
SetMediaDictionaryItem(wPMediaItem, oldUrlForLookup, NOT_FOUND_IMAGE_URL);
return;
}
}
}
var newFile = new MediaFileInfo(uploadPath, theMediaLibraryID);
// Update path and everything to be lowercase and no spaces
newFile.FileName = filePart; // File name without extension, ex "HelloWorld"
newFile.FilePath = pathAndFile.Trim('/'); // Path + File name and extension, exclude the media library folder, ex "/Some-Folder/HelloWorld.jpg"
newFile.FileExtension = ".jpg"; // File extension with period
newFile.FileTitle = mediaTitle.Length > 250 ? mediaTitle.SubString(0, 250) : mediaTitle;
newFile.FileDescription = alt;
// insert the new one
_mediaFileInfoProvider.Set(newFile);
var newUrl = $"/getmedia/{newFile.FileGUID}/{newFile.FileName}{newFile.FileExtension}".ToLower();