完成多个任务的批处理文件或vbscript [英] Batch File or vbscript that completes multiple tasks

查看:77
本文介绍了完成多个任务的批处理文件或vbscript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找对某些进口进行自动化处理的方法.我正在寻找一种调用多个脚本以从一个批处理文件或vbscript运行的方法.我想要做的是以下内容:1)重命名一个文件,该文件是分批完成的 2)将重命名的文件移动到另一个文件夹 3)替换文件中的指定文本 4)重命名带有日期扩展名的文件 我希望能够安排1个批处理文件运行并处理该1个批处理文件中的所有这些任务.我已经写了vbscripts来替换文本,并在完成后移动文件.到目前为止,这是我在批处理中完成的工作.到目前为止,这是我所拥有的,可以帮助您理解我的意思.

I am looking to do some automating on some imports. I am looking for a way to call multiple scripts to run from either one batch file or vbscript. what I am trying to do is the following: 1) rename a file which is done in batch 2) Move the renamed file to another folder 3) Replace specified text within the file 4) Rename the file with a date extension I want to be able to schedule 1 batch file to run and handle all of these tasks from that 1 batch file. I have already written vbscripts to replace text, and move the file when done. Here is what I have so far which is done inside batch. Here is what I have so far which may help you understand what I mean.

(在批处理文件中)

            cd C:\NEW
            ren A353*.txt A353.txt
   (step 2) cscript move1.vbs (which moves the file)
   (step 3) cscript TextReplace.vbs (which replaces a string of text in the A353.txt)
   (step 4) I need a script that will rename A353.txt to the month and date in this format MMDD. EX: A3530823.txt.     

推荐答案

建议不要将批处理和VBScript混合在一起,而是将所有这些任务放在一个VBScript中.这是一个如何在VBScript中重命名文件的示例.

Instead of mixing batch and VBScript, I recommend you just put all those tasks in a single VBScript. Here's an example of how to rename a file in VBScript.

Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.MoveFile "C:\MyFile.txt", "C:\YourFile.txt"
' Can continue to use FSO for other operations...

请注意,移动与重命名本质上是相同的.

Please note that moving is essentially the same thing as renaming.

如果您还需要其他什么,那么将会获得更多帮助.

If you clarify what else you want, then more help will be forthcoming.

这篇关于完成多个任务的批处理文件或vbscript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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