mzibit
mzibit

Reputation: 93

Windows batch script - for using command output

I need to create an script that will list a nfs directory and with this result i need to mapdrivers in specific folder.

Example:

C:\ dir /b \\172.16.30.6\myshare
folder1
folder2
folder3
folder4
folder5
.
.
.

With return of code above, i need to create an for with each folder return to create mklink folder

for /l %%i in (command?) do (
mklink /d "C:\Share\%%i
)

Resuming, i need to create an script that will catch remote dir output and create mklink to each folder

Anyone have some idea to do this?

Thanks!

Upvotes: 1

Views: 194

Answers (1)

Squashman
Squashman

Reputation: 14290

The FOR command with the /D option enumerates directories.

for /D %%G IN ("\\172.16.30.6\myshare\*") do mklink /D "C:\share\%%~nxG" "%%~G"

Upvotes: 3

Related Questions