簡體   English   中英

VBScript filesys.CopyFile到部分隨機的文件夾

[英]VBScript filesys.CopyFile to a folder that is partly random

有人可以幫我解決這個問題嗎?

我在%localappdata%中有一個文件夾,該文件夾是部分隨機的,需要將文件移入其中。

%localappdata%\\ acroprint \\ TQP4_ {字母的隨機字符串} \\ 4.1.15.25435 \\

dim filesys, oShell

Set oShell = CreateObject("WScript.Shell")
strHomeFolder = oShell.ExpandEnvironmentStrings("%LOCALAPPDATA%")

set filesys=CreateObject("Scripting.FileSystemObject") 
If filesys.FileExists("\\tstcfile\public\tqp41_15\user.config") Then 
   filesys.CopyFile "\\tstcfile\public\tqp41_15\user.config", strHomeFolder & "\Acroprint\TQP4_{random string of letters}\4.1.15.25435\", true 
End If

到目前為止,這是我可以使腳本工作的最接近的方法。 我的問題是每個桌面上唯一的數字和字母的隨機字符串。 我知道我不能在目的地使用*。 有誰知道解決方法?

謝謝克里斯

這樣的事情應該起作用:

srcFile = "\\tstcfile\public\tqp41_15\user.config"
parentFolder = filesys.BuildPath(strHomeFolder, "acroprint")

For Each sf In filesys.GetFolder(parentFolder).SubFolders
  If UCase(Left(sf.Name, 5)) = "TQP4_" Then
    filesys.CopyFile srcFile, filesys.BuildPath(sf.Path, "4.1.15.23435\"), True
    Exit For
  End If
Next

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM