導航:首頁 > 文件類型 > vbs獲取文件名

vbs獲取文件名

發布時間:2023-09-20 17:31:40

1. VBS獲取文件名和版本

Setws=CreateObject("WScript.Shell")
SetFSO=CreateObject("Scripting.FileSystemObject")
kugou=ws.regRead("HKCUSoftwareKuGouAppPath")
ForEachfInFSO.GetFolder(kugou).Files
ext=LCase(Right(f.Name,4))
Ifext=".exe"Orext=".dll"Then
s=s&f.Name&vbTab&FSO.GetFileVersion(f.Path)&vbCrLf
EndIf
Next
MsgBoxs

2. vbs怎麼得到自己的文件名

獲取自身文件名的——
Dim fso,f
Set fso = CreateObject("Scripting.FileSystemObject")
f = fso.GetFile(Wscript.scriptfullname).name

--------------------------------------------------

獲取自身完整路徑的
Dim fso,f
Set fso = CreateObject("Scripting.FileSystemObject")
f = fso.GetFile(Wscript.scriptfullname).path

3. vbs獲得當前路徑所有文件夾的名稱

Setfso=CreateObject("scripting.filesystemobject")

Withfso.GetFolder(".")

ForEachSBIn.SubFolders

WScript.Echosb.name

Next

EndWith

4. 如何用vbs獲取指定路徑下的文件名並輸出到文本文件

給你寫個簡單的public function ReplaceStr(FilePath,ExtensioNname,Find,WreplaceStr)on error resume next '繞過讀寫錯誤dim fso,read,list set fso = createobject("scripting.filesystemobject") for each list in fso.getfolder(filepath).files '遍歷文件夾 if fso.getextensionname(list)=ExtensioNname then '判斷文件是否是txt,若是則執行 read=fso.opentextfile(list).readall '讀取全文 if instr(read,find)>0 then '如果txt有要替換的關鍵字則替換,沒有就繞過 read=replace(read,find,wreplacestr) '替換關鍵字 fso.createtextfile(list.path).write read '寫入文本 end if end if next set fso=nothing '釋放內存,這里注意,我沒有重新設定新對象,盡量不要用以免你忘記加上close導致代碼在讀寫時發生錯誤,若一定要用的時候才用,我一般是這樣的end functionreplacestr "e:\1","txt",123,empty '將e:\1文件夾下的所有txt類型文件中的123初始化(即刪除)

5. 通過vbs腳本或者bat腳本,實現獲取文件名和文件大小等信息並輸出到Excel文檔

生成到EXCEL里的不會,但是可以生成CSV文件
自己建一個VBS文件,把下面的代碼扔進去。
可以自己制定路徑,生成C:\1.csv文件。

dim SF,sE,tF
dim fs,oF,sT

sub getFd(fd)
wrtf fd
for each tmpFd in fd.subfolders
getFd tmpFd
next
end sub

sub wrtF(fd)
for each tmpfile in fd.files
sE.write tmpfile.name & "," & tmpfile.size & vbcrlf
next
end sub

sF = InputBox("input your path")

set fs = CreateObject("Scripting.FileSystemObject")
set oF = fs.GetFolder(sF)

tF="C:\1.csv"

if fs.FileExists(tF) then
fs.DeleteFile tF
end if

set sE = fs.OpenTextFile (tF, 8, True)

sE.write "name,size" & vbcrlf

getFd oF

sE.close

msgbox "done!"

閱讀全文

與vbs獲取文件名相關的資料

熱點內容
c圖片寫入資料庫 瀏覽:466
c串口程序 瀏覽:500
中農金融注冊app有哪些 瀏覽:629
回收站文件清理不在電腦上有痕跡 瀏覽:886
dx版本更新 瀏覽:738
主機集群教程 瀏覽:939
蘋果6英版好不好 瀏覽:959
nodejs抓取網站音頻 瀏覽:772
app上下載的軟體在哪裡 瀏覽:36
起凡保存的照片在哪個文件夾 瀏覽:354
數學建模如何把模型編程 瀏覽:176
ug找不到指定的許可文件 瀏覽:850
數控編程g01表示什麼 瀏覽:700
java實用類 瀏覽:190
去年做哪個網站能致富 瀏覽:727
多少的cad版本能打開pdf格式文件 瀏覽:540
win10文件比率是什麼 瀏覽:652
msdb資料庫置疑 瀏覽:210
移動花卡免流app為什麼要10元 瀏覽:147
xamppphp配置文件 瀏覽:268

友情鏈接