Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch to open pdf files with different pdf viewer  (Read 6858 times)

0 Members and 1 Guest are viewing this topic.

luxal

    Topic Starter


    Greenhorn

    batch to open pdf files with different pdf viewer
    « on: June 26, 2010, 12:09:10 AM »
    hello everyone,

    I am trying to create a batch file to open pdf files with different pdf viewers based on folder location.

    Ebooks with adobe digital and pdf docs with foxit.
    So I will place all ebooks in one folder, then via batch file I can choose non-default pdf viewer (Adobe Digital) to open. If the pdf file is anywhere else then it will be open by default pdf viewer - Foxit.

    Any idea how do I do that?

    Thanks

    mat123



      Hopeful

      Thanked: 16
      • Yes
      • Yes
      • Yes
    • Experience: Familiar
    • OS: Windows XP
    Re: batch to open pdf files with different pdf viewer
    « Reply #1 on: June 26, 2010, 09:43:59 AM »
    put this on C:\drive

    if (%1)==() goto bad
    if %~f1==(path to audio books) goto book
    goto pdf
    :book
    start (path to adobe digital) %1
    exit
    :pdf
    start (path to foxit) %1
    exit

    have this as the default program for pdf files. Highlighted parts need to be changed accordingly.



    luxal

      Topic Starter


      Greenhorn

      Re: batch to open pdf files with different pdf viewer
      « Reply #2 on: June 27, 2010, 09:49:26 PM »
      For some reasons it is not working.

      I did all as per your instructions.

      It is showing nothing. No actions at all

      mat123



        Hopeful

        Thanked: 16
        • Yes
        • Yes
        • Yes
      • Experience: Familiar
      • OS: Windows XP
      Re: batch to open pdf files with different pdf viewer
      « Reply #3 on: June 27, 2010, 10:20:20 PM »
      what is the code with the changes made



      luxal

        Topic Starter


        Greenhorn

        Re: batch to open pdf files with different pdf viewer
        « Reply #4 on: June 27, 2010, 10:58:56 PM »
        if (%1)==() goto bad
        if %~f1==D:\My documents\ebooks catalog goto book
        goto pdf
        :book
        start C:\Program Files\PDF Annotator\PDFAnnotator.exe %1
        exit
        :pdf
        start C:\Program Files\Foxit Software\Foxit Reader.exe %1
        exit

        mat123



          Hopeful

          Thanked: 16
          • Yes
          • Yes
          • Yes
        • Experience: Familiar
        • OS: Windows XP
        Re: batch to open pdf files with different pdf viewer
        « Reply #5 on: June 28, 2010, 07:14:33 AM »
        try this

        if (%1)==() goto bad
        if %~f1=="D:\My documents\ebooks catalog" goto book
        goto pdf
        :book
        start "C:\Program Files\PDF Annotator\PDFAnnotator.exe" %1
        exit
        :pdf
        start "C:\Program Files\Foxit Software\Foxit Reader.exe" %1
        exit
        « Last Edit: June 28, 2010, 07:28:20 AM by mat123 »



        luxal

          Topic Starter


          Greenhorn

          Re: batch to open pdf files with different pdf viewer
          « Reply #6 on: June 29, 2010, 08:55:56 PM »
          Sorry, but it is not working.

          Keeps flashing.
          I see cmd window, runs (actually doesn't execute anything) , and exits. Starts again the same steps.

          mat123



            Hopeful

            Thanked: 16
            • Yes
            • Yes
            • Yes
          • Experience: Familiar
          • OS: Windows XP
          Re: batch to open pdf files with different pdf viewer
          « Reply #7 on: June 29, 2010, 09:42:09 PM »

          if (%1)==() goto bad
          if %~f1=="D:\My documents\ebooks catalog" goto book
          goto pdf
          :book
          start "C:\Program Files\PDF Annotator\PDFAnnotator.exe" %1
          echo ebook
          pause
          exit
          :pdf
          start "C:\Program Files\Foxit Software\Foxit Reader.exe" %1
          echo pdf
          pause
          exit
          :bad
          echo no first parameter
          pause
          exit



          tell me the result of this



          luxal

            Topic Starter


            Greenhorn

            Re: batch to open pdf files with different pdf viewer
            « Reply #8 on: June 29, 2010, 11:14:52 PM »
            it keeps opening unlimited cmd windows.
            Last line:
            pause
            Press any key to continue

            Strange

            luxal

              Topic Starter


              Greenhorn

              Re: batch to open pdf files with different pdf viewer
              « Reply #9 on: June 29, 2010, 11:15:33 PM »
              I still keep saving the file on C drive. Not on program files. Could this be an issue?

              mat123



                Hopeful

                Thanked: 16
                • Yes
                • Yes
                • Yes
              • Experience: Familiar
              • OS: Windows XP
              Re: batch to open pdf files with different pdf viewer
              « Reply #10 on: June 30, 2010, 03:11:45 PM »
              if (%1)==() goto bad
              if "%~dp1"=="D:\My documents\ebooks catalog\" goto book
              goto pdf
              :book
              start "C:\Program Files\PDF Annotator\PDFAnnotator.exe" %1
              exit
              :pdf
              start "C:\Program Files\Foxit Software\Foxit Reader.exe" %1
              exit



              luxal

                Topic Starter


                Greenhorn

                Re: batch to open pdf files with different pdf viewer
                « Reply #11 on: July 01, 2010, 12:17:54 AM »
                same situation. Keeps flashing, exits, and starts again.

                I experimented a little bit.

                I removed " " in c: path to both applications foxit and PDF annotator and I get this message:

                "[Window Title]
                C:\Program

                [Content]
                Windows cannot find 'C:\Program'. Make sure you typed the name correctly, and then try again.

                [OK]"


                gpl



                  Apprentice
                • Thanked: 27
                  Re: batch to open pdf files with different pdf viewer
                  « Reply #12 on: July 01, 2010, 12:29:21 AM »
                  Just a thought, put the quotes back in -- and then put the quotes around the %1 -- from the test on your second line, the pdf has spaces in its name also

                  Code: [Select]
                  if (%1)==() goto bad
                  if "%~dp1"=="D:\My documents\ebooks catalog\" goto book
                  goto pdf
                  :book
                  start "C:\Program Files\PDF Annotator\PDFAnnotator.exe" "%1"
                  exit
                  :pdf
                  start "C:\Program Files\Foxit Software\Foxit Reader.exe" "%1"
                  exit

                  mat123



                    Hopeful

                    Thanked: 16
                    • Yes
                    • Yes
                    • Yes
                  • Experience: Familiar
                  • OS: Windows XP
                  Re: batch to open pdf files with different pdf viewer
                  « Reply #13 on: July 01, 2010, 06:01:40 AM »
                  the  %1 provides quotes as needed so that will result in this
                  ""C:\long folder\pdf.pdf""
                  that is not what you want



                  gpl



                    Apprentice
                  • Thanked: 27
                    Re: batch to open pdf files with different pdf viewer
                    « Reply #14 on: July 01, 2010, 08:30:13 AM »
                    yes, you have a point - to get the filename into the batch you would have had to have put quotes around the filename

                    back to the drawing-board