Skip to content

Instantly share code, notes, and snippets.

@fekberg
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fekberg/33e62cf6f06e38d29dce to your computer and use it in GitHub Desktop.
Save fekberg/33e62cf6f06e38d29dce to your computer and use it in GitHub Desktop.
using System.IO;
using System.Linq;
namespace CopyToOneDrive
{
internal class Program
{
private const string _destination = @"C:\Users\YourUserName\OneDrive\Camera Roll";
private const string _source = @"D:\Camera Roll Backup\";
private static void Main(string[] args)
{
var files = new DirectoryInfo(_source).GetFiles();
foreach (var file in files)
{
var oneDriveFiles = new DirectoryInfo(_destination).GetFiles();
// Don't store files using __highres in OneDrive
string filename = file.Name.Replace("__highres", "");
if (!oneDriveFiles.Any(x => x.Name == filename))
{
string highResFileName = file.Name.Replace("Pro.jpg", "Pro__highres.jpg");
string highResFullFileName = Path.Combine(_source, highResFileName);
// Choose the high res version if there is one
if (File.Exists(Path.Combine(_source, highResFileName)))
{
File.Copy(highResFullFileName, Path.Combine(_destination, filename), false);
}
else
{
File.Copy(file.FullName, Path.Combine(_destination, filename), false);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment