fso创建文件夹
Ⅰ vbs鍒涘缓鏂囦欢澶
dimpathname,filename,fso,read,str,filepath
setfso=createobject("scripting.filesystemobject")
pathname="path.txt"
str="ShutdownScript emotecomputer.txt"
iffso.fileexists(pathname)=true锣勬福then'鍏堟潵鍒ゆ柇瀹冩槸涓涓链夋晥镄勮矾寰+鏂囦欢,濡傛灉鎴愮珛,浠ヤ笅鍧囨寜姝e父绋嫔簭镓ц
read=fso.opentextfile(pathname).readall'璇诲彇鍏ㄦ枃
foreachiinsplit(read,vbcrlf)'阆嶅巻鍏ㄦ枃姣忚岀殑鍐呭
ifinstr(right(i,1),"")=0thenfilename=i&""&strelsefilename=i&str'鍦ㄦ墽琛屼笅闱浠g爜涔嫔墠鍏堣繘棰ゆ瘉鎭勮屾牸寮忓寲澶勭悊鏂囨湰
filepath=left(filename,instrrev(filename,""))'鍒嗙昏矾寰
iffso.folderexists(filepath)=falsethenfso.createfolderfilepath'濡傛灉璺寰勫瓨鍦ㄥ垯鍒涘缓鏂囦欢澶
iffso.fileexists(filename)=falsethenfso.createtextfile(filename).write"test"'濡傛灉鏂囦欢浣椤惖瀛桦湪鍒椤垱寤烘枃浠跺啓鍏test
next
endif
Ⅱ 鐢╒BS阃氲繃for寰鐜镓归噺鍒涘缓鏂囦欢澶瑰拰鏂囦欢
Sub locCreateResultFolder()
Dim fso
Dim i,vPath
Set fso = CreateObject("Scripting.FileSystemObject")
vPath = "C:\Program Files\personal\"
fso.CreateFolder "C:\Program Files\personal\"
fso.CreateFolder "C:\Program Files\personal\testFolder"
for i=0 to 100
If Not fso.folderexists(vPath&"testFolder\"&i) Then
fso.CreateFolder(vPath&"testFolder\"&i)
End If
next
End Sub
call locCreateResultFolder
'createfolder鏂规硶鍦ㄨ岃皑鍒涘缓鐩褰曟椂锛屼笂灞傜洰褰曞繀椤诲瓨鍦ㄣ
'钥呰春渚嫔傚垱寤 c:\1\2锛屽傛灉c鐩树笅娌℃湁鐩褰1锛岄偅棣栧甫娲句箞灏变细鍑洪敊锛堜笉鍒涘缓鐩褰2锛夈
Ⅲ VBS濡备綍阃氲繃FSO鍒涘缓镞ユ湡锻藉悕镄勬枃浠跺す锛屽苟鍦ㄦ枃浠跺す閲屽垱寤烘椂闂村懡钖岖殑鏂囨。銆
Const ForReading = 1, ForWriting = 2, ForAppending = 8
AA = "D:\镞﹀瓭"&FormatDateTime(Date, 1)
BB = AA & "\"& hour(time) & Minute(time) & Second(time)&".txt"
Set fso = CreateObject("妯℃竻绋縎cripting.FileSystemObject")
msgbox fso.FolderExists(AA)
IF fso.FolderExists(AA)=FALSE THEN
Set f = fso.CreateFolder(AA)
END IF
Set f = fso.OpenTextFile(BB, ForWriting, True)
f.Write "鍡锛屼綘濂斤紒"姝g噧
f.Close