Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
Computer Hope forum e-mail issues and down time
0 Members and 1 Guest are viewing this topic.
Good MorningCould 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
@echo offTitle Copying All PDF files in folder and its subfolders with drag and dropMode con cols=75 lines=3 & color 0Eset "Drag_Dir=%~1"set "Ext=pdf"echo(IF ["%Drag_Dir%"] EQU [""] Goto:Errorset "newFolder=%Drag_Dir%\New_%Ext%_Folder"Rem Create the new folder to copy all *.pdf on itIf not exist "%newFolder%" md "%newFolder%"2>nul cd "%newFolder%" && Call :CopyPDFfiles || Goto:ErrorEXplorer "%newFolder%"Exit::********************************************:CopyPDFfilesfor /f "delims=" %%I in ('Dir /a-d /b /s "%Drag_Dir%\*.%Ext%"') do ( Copy /Y "%%I" "%newFolder%")Exit /b::********************************************:ErrorMode con cols=75 lines=5 & Color 0Cecho(ECHO You must drag and drop a folder on this batch program ECHO to copy all PDF files in new locationTimeout /T 10 /NoBreak >nulExit /b::*****************************************
It created the folder but no pdf's inside it.
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"?
@echo offTitle Copying All PDF files in folder and its subfolders with drag and dropMode con cols=75 lines=3 & color 0Eset "Drag_Dir=%~1"set "Ext=pdf"set "Word=plan"IF ["%Drag_Dir%"] EQU [""] Goto:Errorset "newFolder=%Drag_Dir%\New_%Ext%_Folder"Rem Create the new folder to copy all *.pdf on itIf not exist "%newFolder%" md "%newFolder%"2>nul cd "%newFolder%" && Call :CopyPDFfiles || Goto:ErrorExplorer "%newFolder%"Exit::********************************************:CopyPDFfilesfor /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::********************************************:ErrorMode con cols=75 lines=5 & Color 0Cecho(ECHO You must drag and drop a folder on this batch program ECHO to copy all PDF files in new locationTimeout /T 10 /NoBreak >nulExit /b::*****************************************
That worked too! Thank you so much! I did not realise so much coding was involved.