Batch File Iterating through files on a local netw

2019-08-29 10:40发布

I'm trying to open various files stored on a local network server with this piece of batch code:

for /f "tokens=*" %%G in ('dir /b /a:d "\\server\directory\*"') do %%G\setup.xml

but since dir \\server\directory doesn't work so won't that piece of code.
How can I accomplish that?

Thank you in advance

2条回答
欢心
2楼-- · 2019-08-29 11:17

You write:

since dir \server\directory doesn't work

At first I was going to say that does work. But what actually works is:

dir \\server\sharename

The server has to share the directory. On the server you can use a command like:

net share public=c:\public

The you should be able to:

dir \\server\sharename
查看更多
仙女界的扛把子
3楼-- · 2019-08-29 11:34

You can map a drive using

net use X: \\server\directory

and then you can change to that directory using

pushd X:

You can then run your batch command on the current directory, and when you are finished and the files are no longer in use, you can delete the drive using

net use X: /delete
查看更多
登录 后发表回答