Last active
August 29, 2015 14:04
-
-
Save fekberg/33e62cf6f06e38d29dce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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