My goal is to make a directory in a sub directory and copy files in the map dir
example:
c:\dir\1
c:\dir\2
etc..............
what i want
c:\dir\1\map
c:\dir\2\map
c:\dir\3\map
etc.................
i know a few commands but that whont work
copy files works whit this command
FOR /R %%g IN (.) DO xcopy *.jpg "%%g\*"
i want the jpg files in a sub dir (map)
so i try this command
FOR /R %%g IN (.) DO md map "%%g\*"
it makes directory's in a loop c:\dir\1\map\map\map\map\...........
c:\dir\2\map\map\map\map\...........
c:\dir\3\map\map\map\map\...........
Who knows the command for creating sub directory's an copy *.jpg files to the created directory
I hope you'll understand i'm dutch sorry
another question..........
is it possible to move files with the same directory name to that directory
c:\map\photo1.jpg (file) (move this file to photo1 map)
c:\map\photo1 (map)
Make directory's in subdir tree and copy files (for command)
Moderator: DosItHelp
Make directory's in subdir tree and copy files (for command)
Last edited by xassnake on 01 May 2011 05:47, edited 1 time in total.
Re: Make directory's in subdir tree and copy files (for comm
One thing isn't clear to me. Do you try to copy only the .jpg files or the entire directory structure as well?
Regards
aGerman
Regards
aGerman
Re: Make directory's in subdir tree and copy files (for comm
only *.jpg files
copy .jpg files to (created map directory)
c:\dir1\map
c:\dir2\map
c:\dir3\map
etc..............
copy .jpg files to (created map directory)
c:\dir1\map
c:\dir2\map
c:\dir3\map
etc..............
Re: Make directory's in subdir tree and copy files (for comm
I see. You could try the following code:
As you can see I prefer to process the DIR command, but it's up to you ...
Regards
aGerman
Code: Select all
@echo off &setlocal
set "root=C:\Dir"
for /f "delims=" %%a in ('dir /ad /b "%root%" 2^>nul') do (
md "%root%\%%~a\map" 2>nul
for /f "delims=" %%b in ('dir /a-d /b /s "%root%\%%a\*.jpg"') do (
copy "%%~b" "%root%\%%~a\map\"
)
)
As you can see I prefer to process the DIR command, but it's up to you ...
Regards
aGerman
Re: Make directory's in subdir tree and copy files (for comm
thank you it works almost good
it makes the right directory and copied the jpg files in it
but my jpg files are in the root and not in sub dir
if i change the command
for /f "delims=" %%b in ('dir /a-d /b /s "%root%\%%a\*.jpg"')
in
for /f "delims=" %%b in ('dir /a-d /b /s "%root%\*.jpg"')
it copies the jpg file from the root to the map dir (c:\dir\dir1\map)
but if i look at the command shell it copies more than there are folders
see my image
there are no copies all jpg files are in the right directory
it makes the right directory and copied the jpg files in it
but my jpg files are in the root and not in sub dir
if i change the command
for /f "delims=" %%b in ('dir /a-d /b /s "%root%\%%a\*.jpg"')
in
for /f "delims=" %%b in ('dir /a-d /b /s "%root%\*.jpg"')
it copies the jpg file from the root to the map dir (c:\dir\dir1\map)
but if i look at the command shell it copies more than there are folders
see my image
there are no copies all jpg files are in the right directory
Re: Make directory's in subdir tree and copy files (for comm
OK if all .jpg files are placed in the root you don't need DIR /S.
Try
Regards
aGerman
Try
Code: Select all
@echo off &setlocal
set "root=C:\Dir"
for /f "delims=" %%a in ('dir /ad /b "%root%" 2^>nul') do (
md "%root%\%%~a\map" 2>nul
copy "%root%\*.jpg" "%root%\%%~a\map\"
)
Regards
aGerman
Re: Make directory's in subdir tree and copy files (for comm
Thank you very much it works great