Need 2 Copy multiple folders from dynamically created folder

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rajeev
Posts: 9
Joined: 10 May 2012 04:26

Need 2 Copy multiple folders from dynamically created folder

#1 Post by rajeev » 03 Aug 2012 04:12

Hi Pals,

I need to copy multiple folders from a dynamically created folder. I'm trying to do it with a batch file. Could
someone help me with this.

Description:

There is a pearl script written which fetches the name of the dynamically created folder.

EX: \\abcde\forsample\dynamic_name\xyz\Wanted (folder needs to be copied)

Thanks,
aBeginner

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Need 2 Copy multiple folders from dynamically created fo

#2 Post by abc0502 » 03 Aug 2012 06:00

is the folder "forsample" has this dynamic folder only or has other folders?

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Need 2 Copy multiple folders from dynamically created fo

#3 Post by abc0502 » 03 Aug 2012 06:44

here this should set the name of your dynamic folder to this variable "%dynamic%"

IF the folder forsample has only one folder whis is the dynamic folder this will work,
just replace the red location with the last static location before the dynamic folder (must be one level between them)
pushd \\abcde\forsample\
For /D %%a in (*) Do set dynamic=%%~na


If it has more than one folder this should work if you know the "Wanted" folder name.
pushd \\abcde\forsample\
For /D %%a in (*) Do (
for /D %%b in (%%~na\xyz\*) Do (
IF /I %%~nb==Wanted set source=%%~fsb
)
)

And also replace the red location with the last static location before the dynamic folder
the %source% variable will be the full location in short form to the wanted folder,
Replace wanted with the name of your folder "folder name not sensitive"

Post Reply