代码必须是VBSCRIPT或Shell脚本

时间:2014-02-09 11:08:55

标签: shell vbscript

您好我需要从文本文件中读取并复制其名称存在于该文件中的文件。文件的位置不同,我需要将它从一个位置复制到另一个位置

Const DestinationFile = "C:\Users\$svijay8\Desktop\libnew\"
Const SourceFile = "C:\Users\$svijay8\Desktop\lib\*"
Dim fso
Dim fName
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(DestinationFile) Then
  WScript.Echo "Folder is there"
Else
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set listFile = fso.OpenTextFile("inputold.txt")
  do while not listFile.AtEndOfStream
    fName =  listFile.ReadLine()
    Set fName = fso.GetFile(C:\Users\$svijay8\Desktop\lib\*so)
    If fname.FileExists("C:\Users\$svijay8\Desktop\lib\*") Then
      WScript.Echo "Reached If loop in do while in If condition above copy"
      fso.CopyFile SourceFile, "C:\Users\$svijay8\Desktop\libnew\", True
    Else
    End If
  loop
End If

1 个答案:

答案 0 :(得分:0)

不确定你的意思“代码必须在VBScript或?? shell ??”。你是说Powershell吗?或CMD.EXE的MS-DOS BATCH命令?或者你在Windows机器上安装了类似Unix的shell(例如bash)吗?

无论如何,你应该能够这样做 - 如果你称之为“shell”。

For /f %%f in (inputold.txt) do copy /y c:\source\%%f c:\dest