VBscript 将文件从一个目录移动到另一个目录 [英] VBscript to move files from one directory to another

查看:49
本文介绍了VBscript 将文件从一个目录移动到另一个目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 VBscript 的新手,想要将特定数量的文件从一个目录移动到另一个目录方面的帮助.

I'm new to VBscript and would like some help on moving a specific number of files from one directory to another.

现在我目前有一组 3 个文件(用于测试目的)具有不同的扩展名,如果源目录中正好有 3 个文件(不多也不少),我想移动所有文件.到目前为止,我的代码是:

Right now I currently have a set of 3 files(for testing purposes) with different extensions and would like to move all of the files if there are exactly 3 files(no more and no less) inside the source directory. My code so far is:

Set fso=CreateObject("Scripting.FileSystemObject")

Set fldr=fso.getFolder("C:\folderA")
for each file in fldr.files
    If fldr.files < 3 then
            msgbox("Need more files")
    Else
            fso.MoveFile "C:\folderA\*", "C:\folderB"
    End If

任何帮助将不胜感激.谢谢大家!

Any help would be greatly appreciated. Thanks, everyone!

推荐答案

  1. 使用 fso.getFolder("C:\folderA").Files.Count 获取C:\folderA 中的文件.
  2. 之前执行此操作 - 而不是在 - 对文件进行循环(移动它们)
  3. 如果文件夹正好包含 3 个文件,请考虑移动(并重新创建)该文件夹
  1. Use fso.getFolder("C:\folderA").Files.Count to get the number of files in C:\folderA.
  2. Do this before - not in - a loop over the files (to move them)
  3. Consider to move (and re-create) the folder if it contains exactly 3 files

这篇关于VBscript 将文件从一个目录移动到另一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆