diff --git a/arduino-core/src/processing/app/Sketch.java b/arduino-core/src/processing/app/Sketch.java
index 6c417403ec9..4563297c82c 100644
--- a/arduino-core/src/processing/app/Sketch.java
+++ b/arduino-core/src/processing/app/Sketch.java
@@ -68,10 +68,10 @@ static public File checkSketchFile(File file) {
     if (pdeName.equals(fileName) || inoName.equals(fileName))
       return file;
 
-    if (altPdeFile.exists())
+    if (FileUtils.fileExistsCaseSensitive(altPdeFile, pdeName))
       return altPdeFile;
 
-    if (altInoFile.exists())
+    if (FileUtils.fileExistsCaseSensitive(altInoFile, inoName))
       return altInoFile;
 
     return null;
diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java
index f2a1603b698..b8843a1284d 100644
--- a/arduino-core/src/processing/app/helpers/FileUtils.java
+++ b/arduino-core/src/processing/app/helpers/FileUtils.java
@@ -309,4 +309,20 @@ public static List<File> listFiles(File folder, boolean recursive,
     return result;
   }
 
+  /**
+   * Checks for the existence of a file with the given name but accounts
+   * for case-sensitivity on case-insensitive file systems.
+   * https://stackoverflow.com/a/34730781
+   *
+   * @param file The file being checked
+   * @param name The actual name the file is expected to have
+   */
+  public static boolean fileExistsCaseSensitive(File file, String name) {
+    try {
+        return file.exists() && file.getCanonicalFile().getName().equals(name);
+    } catch (IOException e) {
+        return false;
+    }
+  }
+
 }