4 Replies Latest reply on Nov 27, 2013 5:20 AM by Sumit_Garg

    Cut and Move files

    BEGINNER_X Level 3

      Hi All,

       

      My request is cut files from the source folder and move into Destination folder.

       

       

       

      Using forum I got the below coding, it should copy from the source folder and paste into Destination Folder.

       

       

       var sourceFolder = Folder.selectDialog("Select Copy Folder")
      
      var destinationFolder = Folder.selectDialog("Select Paste Folder")
      
      function copyFolder(sourceFolder, destinationFolder) {
          var sourceChildrenArr = sourceFolder.getFiles();
          for (var i = 0; i < sourceChildrenArr.length; i++) {
              var sourceChild = sourceChildrenArr[i];
              var destinationChildStr = destinationFolder.fsName + "/" + sourceChild.name;
              if (sourceChild instanceof File) {
                  copyFile(sourceChild, new File(destinationChildStr));
              }
              else {
                  copyFolder(sourceChild, new Folder(destinationChildStr));
              }
          }
      }
      
      
      function copyFile(sourceFile, destinationFile) {
          createFolder(destinationFile.parent);
          sourceFile.copy(destinationFile);
          //sourceFile.move(destinationFile);
      }
      
      
      function createFolder(folder) {
          if (folder.parent !== null && !folder.parent.exists) {
              createFolder(folder.parent);
          }
          folder.create();
      }
      

       

      Please anyone help for the above mentioned request.

       

      Thanks in advance

      Beginner_X