Need help to move directories...

  • Thread starter Thread starter Alexandre
  • Start date Start date
A

Alexandre

Hello to everyone,

Looking for a way to complete the following in batch programming only
:

Sources directories \\servername\share\dir1
\\servername\share\dir2
\\servername\share\dir3
and so on…

Target directories is \\servername\share\dir1
\\servername\share\dir2
\\servername\share\dir3
and so on…

I want to find the directories named : example1, example2 and example3
in the sources directories and move all the examples1,2,3 directories
including subdirectories in the target directory.

I to make it fully automated for each dir1, dir2, dir3 and so on…

I think a need the commands: 'find', 'for' 'move' and/or 'xcopy'.

Please, can you help me ?

Thank you.
 
Alexandre said:
Hello to everyone,

Looking for a way to complete the following in batch programming only
:

Sources directories \\servername\share\dir1
\\servername\share\dir2
\\servername\share\dir3
and so on…

Target directories is \\servername\share\dir1
\\servername\share\dir2
\\servername\share\dir3
and so on…

I want to find the directories named : example1, example2 and example3
in the sources directories and move all the examples1,2,3 directories
including subdirectories in the target directory.

I to make it fully automated for each dir1, dir2, dir3 and so on…

I think a need the commands: 'find', 'for' 'move' and/or 'xcopy'.

Please, can you help me ?
Hello Alexandre,
since the example names in your source and target are identical it's
diffifcult to guess what you want to do.

If example1, example2, example3 stands for a range of folders with the
same prefix and a number you want to locate on a specific server share
and move to a *different* server share you should describe it that way.

Shall the share and basedir names be same on sourve and target?

Please give more specific inforamtion. I've several possible ways in
mind, but don't want to write a fairy tale :-)
 
Matthias Tacke said:
Hello Alexandre,
since the example names in your source and target are identical it's
diffifcult to guess what you want to do.

If example1, example2, example3 stands for a range of folders with the
same prefix and a number you want to locate on a specific server share
and move to a *different* server share you should describe it that way.

Shall the share and basedir names be same on sourve and target?

Please give more specific inforamtion. I've several possible ways in
mind, but don't want to write a fairy tale :-)

Thank you for your reply,

I want to move the contain of some specific directories located into
\\servername\share\dir1 with probably a "for" command... I don't know
how to do that... Example 1,2,3 directories are fixed in source and
destination... This is only the contain that i want to locate... But
for that, i need to parse the directory structure to find example1,2,3
directories and move them into the destination structure. Hope it's
help, thank you :-)
 
Alexandre said:
Thank you for your reply,

I want to move the contain of some specific directories located into
\\servername\share\dir1 with probably a "for" command... I don't know
how to do that... Example 1,2,3 directories are fixed in source and
destination... This is only the contain that i want to locate... But
for that, i need to parse the directory structure to find example1,2,3
directories and move them into the destination structure. Hope it's
help, thank you :-)

Still a bit unclear, but I'll try:

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal
set src=\\servername1\share1
set trg=\\servername2\share2

for %%A in (example1 example2 example3) do (
for /F "delims=" %%B in ('dir "%src%\dir1\%%A" /B/S/AD'
) do set "srcdir=%%~B"&call :sub
)
goto :eof
:sub
call trgdir=%%srcdir:%%src%=%trg%%%
echo move %scrdir% %trgdir%
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

If you can't follow the concept, please give some real, less abstract
examples of your folder structure.

HTH
 
Matthias Tacke said:
Hello Alexandre,
since the example names in your source and target are identical it's
diffifcult to guess what you want to do.

If example1, example2, example3 stands for a range of folders with the
same prefix and a number you want to locate on a specific server share
and move to a *different* server share you should describe it that way.

Shall the share and basedir names be same on sourve and target?

Please give more specific inforamtion. I've several possible ways in
mind, but don't want to write a fairy tale :-)

Thank you for your reply,

I want to move the contain of some specific directories located into
\\servername\share\dir1 with probably a "for" command... I don't know
how to do that... Example 1,2,3 directories are fixed in source and
destination... This is only the contain that i want to locate... But
for that, i need to parse the directory structure to find example1,2,3
directories and move them into the destination structure. Hope it's
help, thank you :-)
 
Matthias Tacke said:
Still a bit unclear, but I'll try:

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal
set src=\\servername1\share1
set trg=\\servername2\share2

for %%A in (example1 example2 example3) do (
for /F "delims=" %%B in ('dir "%src%\dir1\%%A" /B/S/AD'
) do set "srcdir=%%~B"&call :sub
)
goto :eof
:sub
call trgdir=%%srcdir:%%src%=%trg%%%
the word set is missing and a typo with 1 % too much, sorry.
call set trgdir=%%srcdir:%src%=%trg%%%
 
Hi Matthias,

You're very strong in batch programming... As requestered, here is a
simplificated structure of the directories.

C:\rep1\application1\source (this is the source directory!)
C:\rep1\application1\structure (this is the source directory!)

C:\rep1\application2\source (this is the source directory!)
C:\rep1\application2\structure (this is the source directory!)

C:\rep2 (this is an empty destination
directory!)

IMPORTANT: The source and structure directories have files and other
folders into. It is important to move all the contain starting from
source and structure included.

Code that i try...
@echo off
setlocal
set src=C:\rep1
set trg=C:\rep2
for %%A in (source structure) do (
for /F "delims=" %%B in ('dir "%src%\%%A" /B/S/AD'
) do set "srcdir=%%~B"&call :sub
)
goto :eof
:sub
call set trgdir=%%srcdir:%src%=%trg%%%
echo move %scrdir% %trgdir%

If i remove the echo, the script doesn't work.

Thank you again :-)
 
Alexandre said:
Hi Matthias,

You're very strong in batch programming... As requestered, here is a
simplificated structure of the directories.

C:\rep1\application1\source (this is the source directory!)
C:\rep1\application1\structure (this is the source directory!)

C:\rep1\application2\source (this is the source directory!)
C:\rep1\application2\structure (this is the source directory!)

C:\rep2 (this is an empty destination
directory!)

IMPORTANT: The source and structure directories have files and other
folders into. It is important to move all the contain starting from
source and structure included.

Code that i try...
@echo off
setlocal
set src=C:\rep1
set trg=C:\rep2
for %%A in (source structure) do (
for /F "delims=" %%B in ('dir "%src%\%%A" /B/S/AD'
) do set "srcdir=%%~B"&call :sub
)
goto :eof
:sub
call set trgdir=%%srcdir:%src%=%trg%%%
echo move %scrdir% %trgdir%

If i remove the echo, the script doesn't work.

Thank you again :-)
Hi Alexandre,
I'm a bit confused and frustrated (may be due to a bottle of red wine).

At first your source and target where different servers and now they're
on your c: drive?
My batch was intended to first iterate through your example1-3 folders,
the second for invokes a dir a command to sieve the whole tree starting
(as you stated) in \\server\share\dir1.
The server part of the matching folder names should then be exchanged
with your proposed target.

What output did you get with the echo? Did it seem to fit your needs?

May be I can get a grip on it tomorrow ;-)
 
Hello to everyone,

Looking for a way to complete the following in batch programming only
:

Sources directories \\servername\share\dir1
\\servername\share\dir2
\\servername\share\dir3
and so on…

Target directories is \\servername\share\dir1
\\servername\share\dir2
\\servername\share\dir3
and so on…

I want to find the directories named : example1, example2 and example3
in the sources directories and move all the examples1,2,3 directories
including subdirectories in the target directory.

I to make it fully automated for each dir1, dir2, dir3 and so on…

I think a need the commands: 'find', 'for' 'move' and/or 'xcopy'.

Like Matthias, I'm not quite sure what exactly you want to do, but the
programs xxcopy or RoboCopy (my favourite) have a sufficiently rich set
of options that they should be able to do whatever it is you want to do.
Both require reading their documentation.
 
Hi Alexandre,
I'm a bit confused and frustrated (may be due to a bottle of red wine).

At first your source and target where different servers and now they're
on your c: drive?
My batch was intended to first iterate through your example1-3 folders,
the second for invokes a dir a command to sieve the whole tree starting
(as you stated) in \\server\share\dir1.
The server part of the matching folder names should then be exchanged
with your proposed target.

What output did you get with the echo? Did it seem to fit your needs?

May be I can get a grip on it tomorrow ;-)


Hi Mattias,
Thank you for your reply and sorry if the english are wrong :-(
Here is the detailled operations that i want with.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1. Parent server path: \\servername\share\application1\source(and
structure) directories.
2. Child server path: \\servername\share\application1\source(and
structure)directories.
3. I have a lot of application(x) directories in parent server with
multiples different names (application1 directory are not fixed, other
names can be also)and the Source and Structure directories are always
here.
4. The child server has the same whole structure of the parent, but
without the files of the parent source and structure directories into.

The code must be able to parse all the parent server directories to
find all the source and structure directories and move them with all
the subdirectories with files into the same path in child server.

If it is possible, can you put a log file after the move have done the
task? The log file contain all the moves the the program has been
done.

I know that i can solve my problem with xxcopy (i have RTFM :-)) and
enter the two lines of code, but i'm sure that it's can be solved with
batch programming and to not have a product to call to do the work.

P.S. If you would, can you put comments to the "tricky" parts of your
code, just for learning purpose of myself and the community ? :-)

Many thanks,

A
 
Alexandre said:
Hi Mattias,
Thank you for your reply and sorry if the english are wrong :-(
Here is the detailled operations that i want with.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<snip>

Sorry Alexandre,
my patience has an end. I'm not willing to repeat again the very same
questions you resist to answer or to find a solution just for your
curiousity when xxcopy can do the job.

Read (and try to understand) the manuals. Follow my signature if you
want learn more on batching.

May be someone is out there to take over.

Bye
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
 
:
Sorry Alexandre,
my patience has an end. I'm not willing to repeat again the very same
questions you resist to answer or to find a solution just for your
curiousity when xxcopy can do the job.

Read (and try to understand) the manuals. Follow my signature if you
want learn more on batching.

May be someone is out there to take over.
Just to close (for my part) this thread, my answer to Alexandre via pm:
----------------------------------------------------------------------
My mailfilter is very strict, so I saw your response via pm just now.

After having seen a mail from you with some bad words in the subject,
my motivation to help you in my spare time is very low.

Your examples showed all the time the same names for source and target
what is impossible to handle.

Normal copies/moves of subtrees will be handled by the /s switch.
You didn't make clear where your real problem is, and I don't know
if this was due to understanding of the language. My tone was always
kind and never meant as an attack.

Nobody is forced to use newsgroups for helping or searching for
help. If I don't see progress in 3 rounds of messages I simply stop.
You did *not* answer my questions. Also Michael Bednarek couldn't see
how to help, so it's not just me.

I and most of the regulars in the groups prefer to have the
conversation in the group and not via pm - google allows others to
participate on the knowledge gathered this way.

Greetings
Matthias
 
In said:
:

Just to close (for my part) this thread, my answer to Alexandre
via pm:
-------------------------------------------------------------------
--- My mailfilter is very strict, so I saw your response via pm
just now.

After having seen a mail from you with some bad words in the
subject, my motivation to help you in my spare time is very low.

Your examples showed all the time the same names for source and
target what is impossible to handle.

Normal copies/moves of subtrees will be handled by the /s switch.
You didn't make clear where your real problem is, and I don't know
if this was due to understanding of the language. My tone was
always kind and never meant as an attack.

Indeed. You were attempting to be helpful from my perspective.
Posters requiring help need to cooperate with those willing to try.

FWIW I too did not see the OP as having provided the requested
information and maintain a courteous dialog.
[ ]
 
Back
Top