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

Author Topic: finding/moving files  (Read 3186 times)

0 Members and 1 Guest are viewing this topic.

widetree

    Topic Starter


    Greenhorn

    • Experience: Experienced
    • OS: Windows 8
    finding/moving files
    « on: April 20, 2017, 03:59:27 AM »
    Good Morning

    Could someone tell me what the dos cmd is to find all pdf files in all sub directories and copy them to a named folder please.

    Thank you


    Hackoo



      Hopeful
    • Thanked: 42
    • Experience: Expert
    • OS: Windows 10
    Re: finding/moving files
    « Reply #1 on: April 20, 2017, 04:39:36 AM »
    Good Morning

    Could someone tell me what the dos cmd is to find all pdf files in all sub directories and copy them to a named folder please.

    Thank you
    Hi  ;)
    Did you mean move or copy them in new folder ?

    widetree

      Topic Starter


      Greenhorn

      • Experience: Experienced
      • OS: Windows 8
      Re: finding/moving files
      « Reply #2 on: April 20, 2017, 05:21:57 AM »
      To copy please

      Hackoo



        Hopeful
      • Thanked: 42
      • Experience: Expert
      • OS: Windows 10
      Re: finding/moving files
      « Reply #3 on: April 20, 2017, 06:59:51 AM »
      Hi  :)
      You can give a try with this batch file : CopyPDF.bat
      Just copy and paste this code with your notepad and save it as CopyPDF.bat and just drag and drop your folder on it. ;)

      Code: [Select]
      @echo off
      Title Copying All PDF files in folder and its subfolders with drag and drop
      Mode con cols=75 lines=3 & color 0E
      set "Drag_Dir=%~1"
      set "Ext=pdf"
      echo(
      IF ["%Drag_Dir%"] EQU [""] Goto:Error
      set "newFolder=%Drag_Dir%\New_%Ext%_Folder"
      Rem Create the new folder to copy all *.pdf on it
      If not exist "%newFolder%" md "%newFolder%"
      2>nul cd "%newFolder%" && Call :CopyPDFfiles || Goto:Error
      EXplorer "%newFolder%"
      Exit
      ::********************************************
      :CopyPDFfiles
      for /f "delims=" %%I in ('Dir /a-d /b /s "%Drag_Dir%\*.%Ext%"') do (
          Copy /Y "%%I" "%newFolder%"
      )
      Exit /b
      ::********************************************
      :Error
      Mode con cols=75 lines=5 & Color 0C
      echo(
      ECHO           You must drag and drop a folder on this batch program
      ECHO                 to copy all PDF files in new location
      Timeout /T 10 /NoBreak >nul
      Exit /b
      ::*****************************************
      « Last Edit: April 20, 2017, 07:55:21 AM by Hackoo »

      widetree

        Topic Starter


        Greenhorn

        • Experience: Experienced
        • OS: Windows 8
        Re: finding/moving files
        « Reply #4 on: April 20, 2017, 07:41:51 AM »
        Thank you Hacko.

        It created the folder but no pdf's inside it.

        Hackoo



          Hopeful
        • Thanked: 42
        • Experience: Expert
        • OS: Windows 10
        Re: finding/moving files
        « Reply #5 on: April 20, 2017, 07:49:12 AM »
        It created the folder but no pdf's inside it.
        Check if your folder and its subfolders contains any pdf files or not !
        if the batch file dosen't find any pdf files it create an empty folder named New_PDF_Folder

        widetree

          Topic Starter


          Greenhorn

          • Experience: Experienced
          • OS: Windows 8
          Re: finding/moving files
          « Reply #6 on: April 20, 2017, 08:13:16 AM »
          Yes that worked beautifully! Thank you very much! Could you possibly tweet the code so I could run this batch file to find pdf's with a name containing the characters "plan"?

          Hackoo



            Hopeful
          • Thanked: 42
          • Experience: Expert
          • OS: Windows 10
          Re: finding/moving files
          « Reply #7 on: April 20, 2017, 08:36:18 AM »
          Yes that worked beautifully! Thank you very much! Could you possibly tweet the code so I could run this batch file to find pdf's with a name containing the characters "plan"?
          Here we go  ;)
          Code: [Select]
          @echo off
          Title Copying All PDF files in folder and its subfolders with drag and drop
          Mode con cols=75 lines=3 & color 0E
          set "Drag_Dir=%~1"
          set "Ext=pdf"
          set "Word=plan"
          IF ["%Drag_Dir%"] EQU [""] Goto:Error
          set "newFolder=%Drag_Dir%\New_%Ext%_Folder"
          Rem Create the new folder to copy all *.pdf on it
          If not exist "%newFolder%" md "%newFolder%"
          2>nul cd "%newFolder%" && Call :CopyPDFfiles || Goto:Error
          Explorer "%newFolder%"
          Exit
          ::********************************************
          :CopyPDFfiles
          for /f "delims=" %%I in ('Dir /a-d /b /s "%Drag_Dir%\*.%Ext%" ^| find /I "%Word%"') do (
          Rem find all pdf's with a name containing the characters "plan" and copy them to the newfolder
              Copy /Y "%%I" "%newFolder%"
          )
          Exit /b
          ::********************************************
          :Error
          Mode con cols=75 lines=5 & Color 0C
          echo(
          ECHO           You must drag and drop a folder on this batch program
          ECHO                 to copy all PDF files in new location
          Timeout /T 10 /NoBreak >nul
          Exit /b
          ::*****************************************
          « Last Edit: April 20, 2017, 09:11:48 AM by Hackoo »

          widetree

            Topic Starter


            Greenhorn

            • Experience: Experienced
            • OS: Windows 8
            Re: finding/moving files
            « Reply #8 on: April 21, 2017, 12:14:51 AM »
            That worked too! Thank you so much! I did not realise so much coding was involved.

            Hackoo



              Hopeful
            • Thanked: 42
            • Experience: Expert
            • OS: Windows 10
            Re: finding/moving files
            « Reply #9 on: April 21, 2017, 04:14:29 AM »
            That worked too! Thank you so much! I did not realise so much coding was involved.
            You are welcome dude and don't forget to use the Thanks link  ;D
            Have a nice day !  ;)