I need to be able to copy only the files out of several directories and place them into one directory.
I have one directory and within that directory I have about 5 other directories. Within each of those 5 directories there are about 50 or so .tiff files.
I need to copy only the .tiff files into a single directory.
Right now I have the following command:
FOR /f %%I IN ("%userprofile%\desktop\output\*.tif") DO xcopy /s "%%I" "%userprofile%\desktop\hf"
This moves the .tiff files but it also moves the 5 directories as well, and I need it just to move the .tiff files and just lump them into one directory.
Any Ideas?
Copying all Files within directories to one directory
Moderator: DosItHelp
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Your for loop is quite superfluous. All you're actually doing is this:
A variation on this should work for you:
Or perhaps:
Code: Select all
xcopy /s "%userprofile%\desktop\output\*.tif" "%userprofile%\desktop\hf"
A variation on this should work for you:
Code: Select all
for /R "%userprofile%\desktop\output" %%a in (*.tif) do copy "%%~a" "%userprofile%\desktop\hf"
Or perhaps:
Code: Select all
for /f %%a in ('dir /b /s /a-d "%userprofile%\desktop\output\*.tif"') do copy "%%~a" "%userprofile%\desktop\hf"