Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

VBScript script implements the automatic acquisition of a file in the directory

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

1. Application scenario: multiple bulid of this version or historical version are usually retained on the development stream. How to script the latest build installation in the directory (there are many files with different names except build in the directory)? And there are usually version numbers that increase in turn in the naming of build, so how to make the script reusable every day?

2. Implementation idea: 1 > deal with the file name, define a constant file name, and replace the changed version number in the file name with *.

2 > given a known directory, get all the sub-files under the directory, and then split them by *, matching the file names of the sub-files and the names of the two parts of the split in turn.

3. The code is as follows:

'Description:fetch new build'author:Alan'Date:2014-10-31Function strFetchBuild (path,filename) Dim iLINAES FileNames = aGetAllFillname (path) If IsEmpty (FileNames) = false and IsArray (FileNames) Then' whether the filename format is right or not If Instr (filename, "*") > 0 Then 'according to * split filename splits=Split (filename) "*") For iTun0 To UBound (FileNames) flag=0'If each split block are matched, then return name For j = 0 To UBound (splits) If Instr (FileNames (I) Splits (j)) > 0 Then flag=flag+1 End If Next If flag= UBound (splits) + 1 Then strFetchBuild = path & "\" & FileNames (I) Else'If didn't match to the end of the loop Then exit function If i=UBound (FileNames) + 1 Then Log.Error ("The file:" & filename & "not found.") StrFetchBuild = "" Exit Function End If End If Next Else Log.Error ("The filename format" & "'& filename &" & "is not right.") StrFetchBuild = "" Exit Function End If Else Log.Error ("The path:" & path & "not exists.") StrFetchBuild = "" End If End Function

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report