fso創建文件夾-ag真人国际官网
ⅰ 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