multiple file type search
Moderator: DosItHelp
-
- Posts: 10
- Joined: 21 Nov 2011 23:43
multiple file type search
is there any command to search all the *.doc, *.pdf, *.xls created after 2010.Jan.1 inside the C drive (including sub-directory)
then copy above files to D drive? thanks
then copy above files to D drive? thanks
-
- Posts: 25
- Joined: 24 Feb 2009 14:52
- Location: UK
- Contact:
Re: multiple file type search
Try this simple batch file. change the second line to point to your own destination folder on drive D:.
Code: Select all
@echo off
set destination=d:\temp
md %destination% 2>nul
for %%a in (doc pdf xls) do (
xcopy "*.%%a" "%destination%" /c /d:11-1-2011 /s
)
-
- Posts: 10
- Joined: 21 Nov 2011 23:43
Re: multiple file type search
I already has directory temp, no need to md.
should I use:
@echo off
for %%a in (doc pdf xls) do (
xcopy "*.%%a" "%destination%" /c /d:11-1-2011 /s
)
how to exclude doc and xls inside windows directory, I don't know the exact location of windows installation path.
should I use:
@echo off
for %%a in (doc pdf xls) do (
xcopy "*.%%a" "%destination%" /c /d:11-1-2011 /s
)
how to exclude doc and xls inside windows directory, I don't know the exact location of windows installation path.
-
- Posts: 25
- Joined: 24 Feb 2009 14:52
- Location: UK
- Contact:
Re: multiple file type search
Don't for get to set your destination path after the '=' on the 2nd line or hardcode it into the xcopy command.
Code: Select all
@echo off
set destination=
echo %windir%>exclude.tmp
for %%a in (doc pdf xls) do (
xcopy "*.%%a" "%destination%" /c /d:11-1-2011 /s /exclude:exclude.tmp
)
del exclude.tmp
-
- Posts: 10
- Joined: 21 Nov 2011 23:43
Re: multiple file type search
I save this batch file in c:\, after that I run the batch, it says can't perform a cycle copy, 0 files copied
if I put this batch file in c:\abc, only abc folder document file are copied.
how to solve the problem?
@echo off
set destination=c:\ttmp
echo %windir%>exclude.tmp
for %%a in (doc pdf xls ppt) do (
xcopy "*.%%a" "%destination%" /c /s /exclude:exclude.tmp
)
del exclude.tmp
if I put this batch file in c:\abc, only abc folder document file are copied.
how to solve the problem?
@echo off
set destination=c:\ttmp
echo %windir%>exclude.tmp
for %%a in (doc pdf xls ppt) do (
xcopy "*.%%a" "%destination%" /c /s /exclude:exclude.tmp
)
del exclude.tmp
-
- Posts: 10
- Joined: 21 Nov 2011 23:43
Re: multiple file type search
my requirement is copy files from the whole c drive including subdirectory, not copy files from current directory
Re: multiple file type search
There are several possibilities.
Regards
aGerman
Code: Select all
for /r "C:\" %%i in (*.doc *.pdf *.xls *.ppt) do ... [whatever you want to do with the files]
Regards
aGerman
Re: multiple file type search
programchen wrote:I save this batch file in c:\, after that I run the batch, it says can't perform a cycle copy, 0 files copied
Of course that is going to happen if you execute it from the root of the drive. You said earlier that you wanted to copy to the D: drive though. If you were copying to a separate drive then you would not get the cyclical copy error. You can't say you want to copy from the root of the whole drive and then copy to a folder on that same drive. That is a cyclical copy.
-
- Posts: 10
- Joined: 21 Nov 2011 23:43
Re: multiple file type search
thanks, I want to copy those files to d drive, after copy, delete those files in c drive (including subdirectory)
how to resolve?
how to resolve?
Re: multiple file type search
programchen wrote:after copy, delete those files in c drive
robocopy /? Have a look at the /mov option.
programchen wrote:(including subdirectory)
Are you sure?
Imagine there is a .doc file in c:\whereever\sub1 and another .doc file in c:\whereever\sub1\sub2. What happen if the first .doc is copied and sub1 is removed? ... Also what about other file types in these directories?
Regards
aGerman