6 Replies Latest reply on Aug 25, 2015 1:14 AM by Ronald63

    move an indesign document

    aviR

      Hello All

      Can anyone please tell me How to move an indesign document to  SPECIFIED PATH?

      Is there any direct method?

      Please Please Help

      thanks.

        • 1. Re: move an indesign document
          Ronald63 Level 4

          Hello,

           

          Use this ...

          var sourcePath = File('~/Desktop/foo_1.indd');
          var targetPath = File('~/Documents/foo_2.indd');
          
          sourcePath.copy(targetPath);
          
          

          Regards

          • 2. Re: move an indesign document
            aviR Level 1

            Hii,

             

            Thanks for your immediate response. I will try this but through vb.net and get back to you soon.

            • 3. Re: move an indesign document
              aviR Level 1

              hi

              This doesnot move the document. Can u Please tell me any other method?

              Please help.

              Thank You

              • 4. Re: move an indesign document
                Ronald63 Level 4

                Can you post your code ...

                • 5. Re: move an indesign document
                  aviR Level 1

                  Dim idFiles As String = "E:\abcd\file4copy"

                              Directory.CreateDirectory(idFiles)

                              Directory.SetCurrentDirectory(idFiles)

                             

                              For Each GetFiles As String In My.Computer.FileSystem.GetFiles(idFiles, Microsoft.VisualBasic.FileIO.SearchOption.SearchAllSubDirectories, "*.indd")

                                  Try

                                      Dim filename As String = GetFiles.Split("\").Last

                                      My.Computer.FileSystem.CopyFile(GetFiles, unprocessedpath + "\" + filename)

                                  Catch ex As Exception

                   

                   

                                  End Try

                              Next

                   

                  I am using the copy method to copy the file in the target folder. And it's working but then I want to remove or delete the original file but it's not happening.

                  doc.delete() or doc.remove() is not coming. So what can I do now? How to delete the original file? Or is there any method to completely move the file without coping?

                  Please help.

                  Thanks

                  • 6. Re: move an indesign document
                    Ronald63 Level 4

                    Another way from http://kasyan.ho.com.ua/snippets/file_folder.html

                    function MoveFile(myFile, myFolder) {
                        if (!myFile instanceof File || !myFolder instanceof Folder || !myFile.exists || !myFolder.exists) return false;
                        var myMovedFile = new File(myFolder.absoluteURI + "/" + myFile.name);
                        if (myMovedFile.exists) return false;
                        if (File.fs == "Windows")  {
                            var myVbScript = 'Set fs = CreateObject("Scripting.FileSystemObject")\r';
                            myVbScript +=  'fs.MoveFile "' + myFile.fsName + '", "' + myFolder.fsName + '\\"';
                            app.doScript(myVbScript, ScriptLanguage.visualBasic);
                        }
                        else if (File.fs == "Macintosh") {
                            var myAppleScript = 
                            'tell application "Finder"\r' +
                            'move POSIX file "' + myFile.fsName + '"  to POSIX file "' + myFolder.fsName + '" with replacing\r' +
                            'end tell\r'
                            app.doScript(myAppleScript, ScriptLanguage.applescriptLanguage);
                        }
                        if (myMovedFile.exists) {
                            return true;
                        }
                        else {
                            return false;
                        }
                    }