如何用命令计数共享文件并返回变量?
这是我使用的代码。
for /f %%a in ('"dir /a:-d /s /b %Path%|find /c ":\""') do set check=%%a
此命令可以在本地环境下正确运行,并返回变量“检查”。 (这意味着%path%中的文件有多少个文件)
但是,当将%路径%设置为共享路径时,变量“检查”始终返回0。
即使我可以使用dir%path%
。
如何修复代码以从共享文件夹返回变量?
Here is the code that I used.
for /f %%a in ('"dir /a:-d /s /b %Path%|find /c ":\""') do set check=%%a
This command can run correctly under the local environment, and return the variable "check".
(That means how many files in the %Path%)
However, when setting up the %Path% to shared path, the variable "check" always return 0.
Even I can use dir %Path%
successfully.
How to fix the code to return variable from shared folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行该搜索的另一种方法是计算不是空白的项目数量。因此,您可以这样执行搜索:
我同意斯蒂芬的观点,即您不应将%路径%作为变量。另外,您应该在设定命令周围使用引号。如果这不起作用,我们需要知道路径变量的确切名称和位置。
Another way to perform that search is to count the number of items which are not blank. So, you could perform the search like this:
I agree with Stephan that you should not use %PATH% as your variable. Also, you should use quotes around the set command. If this doesn't work, we'd need to know the exact name and location of your path variable.