Search and copy all files with a particular ext

Hi,

I want a script to copy any type of file ext i specify.
like "jpeg" search for jpeg file in all the drives in the machine and copy any files found to the path specified.

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
 
canaliCommented:
Hoping nothing go wrong wmic command...

@echo off
setlocal
:: *** remove REM if u don't want output
REM set NoOUTPUT=^>nul 2^>^&1

::Creation of destination folder
%NoOUTPUT% mkdir c:\temp
%NoOUTPUT% mkdir c:\temp\img
:: ***set the destination folder
set copyTO=c:\temp\img

:: *** Looking For
:: change or add new exts
set lookFOR=*.jpg *.gif *.png *.bmp *.psd
for /f %%c in ('type c:\computers.txt') do (
  ((ping -n 2 -w 500 %%c|find /i "TTL" 1>null )&&  call :_FFinPC %%c  2>nul)||echo %%c: switched off
)
goto :_END
:_FFinPC
 set d=
 for /f "skip=1 delims=:" %%h in ('WMIC.EXE /Node:"%1"  path win32_LogicalDisk where drivetype^="3" get caption') do (
 set d=%%h
 call :_look4in \\%1\%%h$
)
goto :_EOF
:_look4in
echo look in %1 for %lookFOR%
echo for /r "%1" %%F in (%lookFOR%) do
for /r "%1" %%F in (%lookFOR%) do  (
  %NoOUTPUT% echo %%F
  %NoOUTPUT% copy "%%F" "%copyTO%"
)
goto :_EOF
:_END
:_EOF
0
 
biggstrcCommented:
I don't have a script, but a quick solution would be to use a file-copy program like Karen's Replicator (http://www.karenware.com/powertools/ptreplicator.asp).  You can set a filter on a job so that it only selects the file types you want.  The downside with Karen's is that it will create a directory tree that replicates what is on the source drive.  If this is a problem, I would look for another program like this one to do the job.  If you are a VB programmer, you could use the source code for Karen's to modify it to your needs.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.