通过 VBScript 打开、读取、写入网络附加存储上的文件
我有数千个小 CSV 文件想要聚合(首先在脚本中进行一些修改)。它们位于 NAS 设备上,更准确地说,是“SNAP”服务器。我在 Excel 中使用 VBA 取得了一些成功 - 如果我没记错的话(大约一个月前),大约一分钟内处理了大约 700 个文件。实际上,这是成功了一半:snap 服务器存储了 80% 的 pdf 和一些专有格式文件,而只有 20% 的 CSV。测试文件类型的循环执行时间超过 2 小时,并且脚本显然完全忽略了我放入的日期过滤。快速结果或“成功”是在我制作并放在 C 驱动器上的 CSV 的 700 个副本上。我从事 VBA 脚本编写工作已经近 20 年了,我认为我在这方面做得不错;在过去的 9 年里,我通过 VBA 进行了大量的 CSV 读写工作。所以我的问题更多的是关于您对 Snap 服务器或 NAS 的总体体验。
我是否不能像使用 VBA 处理任何驱动器/文件夹一样对待快照服务器?
VBScript 会更合适吗? (毕竟已经使用了 FileSystemObject)
如果我可以使用VBS,我可以将脚本存储在NAS上并使用taskscheduler运行它吗? 我非常感谢那些有使用 snap 服务器经验的人提供的任何提示或陷阱!
I have thousands of small CSV files I want to aggregate (with a little munging in-script first). They are on a NAS device, a "SNAP" Server to be more exact. I've had some success with VBA from Excel - doing about 700 files in about a minute, if I recall (was a month ago). Actually, it was half-success: the snap server is home to 80% pdfs and some proprietary-format files and only 20% CSVs. The Loop to test for filetype took the execution time north of 2 hours and the script apparently completely ignored date filtering I put in. The quick result or 'success' was on 700 copies of the CSVs I made and put on my C drive. I've been doing VBA scripting for almost 20 years, and I think I'm decent at it; I do a lot of CSV reading and writing from VBA the last 9 years. So my question is more about your experience with snap servers or NAS generally.
Can I not treat the snap server more or less like any drive/folder with VBA?
Would VBScript be more appropriate? (already using FileSystemObject, after all)
If I can use VBS can I store the script on the NAS and run it using taskscheduler?
I'd appreciate any tips or gotchas from you folks who have experience with snap servers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于语言选择的一些想法:
VB Script 比 VBA 更轻量,因为它不需要安装 MS Office。语法相似,因此不存在真正的生产力差异。
展望未来,强烈建议将 Powershell 用于 Windows 系统管理任务、一般文本文件处理等。
关于使用 NAS 服务器的一些想法:
a) 如果在工作站上运行脚本,您应该能够使用用于连接到 NAS 上共享的 URI 字符串 \\myserver\myshare。如果没有,您可能需要在脚本运行之前将驱动器号映射到该共享。
b) 如果您想在 NAS 上运行脚本,需要考虑 2 件事:NAS 操作系统是否已锁定,以便您无法添加自己的计划任务,是 Linux 还是某些 Windows 版本。许多 NAS 产品使用嵌入式 Linux,因此直接在 NAS 上运行 VBA 或 VBScript 解决方案可能无法工作,除非它基于嵌入式 XP 之类的东西,并且您可以访问计划任务等。
希望这会有所帮助...
Some thoughts on the choice of language:
VB Script is more lightweight than VBA in that it does not require MS Office to be installed. The syntax is similar so there is no real productivity difference.
Moving forward Powershell would be strongly recommended for Windows system admin tasks, general text file processing, etc.
Some thoughts on using the NAS server:
a) If running your script on a workstation you should be able to use a URI string \\myserver\myshare to connect to a share on the NAS. If not you may need to map a drive letter to that share before your script runs.
b) If you want to run your script on the NAS there are 2 things to consider: is the NAS OS locked so that you may not add your own scheduled task and is it Linux or some flavor of Windows. Many NAS products use embedded Linux so running a VBA or VBScript solution directly on the NAS may not work unless it is based on something like Embedded XP and you have access to Scheduled Tasks, etc.
Hope this helps...