Computer Hope
Microsoft => Microsoft DOS => Topic started by: widetree 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
-
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 ?
-
To copy please
-
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. ;)
@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
::*****************************************
-
Thank you Hacko.
It created the folder but no pdf's inside it.
-
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
-
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"?
-
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 ;)
@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
::*****************************************
-
That worked too! Thank you so much! I did not realise so much coding was involved.
-
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 ! ;)