diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java
index e68ca47783b..6e3719ee6da 100644
--- a/app/src/processing/app/Editor.java
+++ b/app/src/processing/app/Editor.java
@@ -72,6 +72,8 @@
 import static processing.app.I18n.tr;
 import static processing.app.Theme.scale;
 
+import processing.app.helpers.FileUtils;
+
 /**
  * Main editor panel for the Processing Development Environment.
  */
@@ -1900,7 +1902,7 @@ protected boolean handleOpenInternal(File sketchFile) {
         // copy the sketch inside
         File properPdeFile = new File(properFolder, sketchFile.getName());
         try {
-          Base.copyFile(sketchFile, properPdeFile);
+          FileUtils.copy(new File(sketchFile.getParent()), properFolder);
         } catch (IOException e) {
           Base.showWarning(tr("Error"), tr("Could not copy to a proper location."), e);
           return false;
diff --git a/arduino-core/src/processing/app/helpers/FileUtils.java b/arduino-core/src/processing/app/helpers/FileUtils.java
index 5e30319dc6a..654a5d95adc 100644
--- a/arduino-core/src/processing/app/helpers/FileUtils.java
+++ b/arduino-core/src/processing/app/helpers/FileUtils.java
@@ -58,6 +58,10 @@ public static void copyFile(File source, File dest) throws IOException {
   public static void copy(File sourceFolder, File destFolder) throws IOException {
     for (File file : sourceFolder.listFiles()) {
       File destFile = new File(destFolder, file.getName());
+      if ((destFolder.getPath().equals(file.getPath()))) {
+          // Avoid recursive copy of folders
+          continue;
+      }
       if (file.isDirectory() && !SOURCE_CONTROL_FOLDERS.contains(file.getName())) {
         if (!destFile.exists() && !destFile.mkdir()) {
           throw new IOException("Unable to create folder: " + destFile);