Dim strRoot As String '初始路径
Dim strOldName As String
Dim colOldNames As New Collection '旧路径名集合
Dim colNewNames As New Collection '准备修改的新路径名集合
Dim i As Integer
'获取旧路径名序列
strOldName = Dir(strRoot, vbDirectory)
Do While strOldName <> ""
If strOldName <> "." And strOldName <> ".." And (GetAttr(strRoot & strOldName) And vbDirectory) = vbDirectory Then
colOldNames.Add strOldName
End If
strOldName = Dir(, vbDirectory)
Loop
'替换文件夹名
'这里假设已存在的路径名序列数量小于等于你文本文件中的数据行数,否则报错
For i = 1 To colOldNames.Count
Name strRoot & colOldNames(i) As strRoot & colNewNames(i)
Next
结贴吧
#9
完全菜鸟 不会用 保存为.VBS 打开提示语句为结束
#10
得了.最好手把手把你电脑上的都改好算了....
#11
靠!!不早说要VBS
#12
都懒得再写了,你纠结两天的时间,手工挨个也改完了
#13
熟悉一下for在批处理中的使用。
C:\>
for /? 对一组文件中的每一个文件执行某个特定命令。
FOR %variable IN (set) DO command [command-parameters]
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
或者,如果有 usebackq 选项:
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
Dim fso, theFile, ReadEntireFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(fso.GetFolder(".").Path & "\标题.txt", 1, False)
Do While theFile.AtEndOfStream <> True
ReadEntireFile = ReadEntireFile & theFile.ReadLine & vbcrlf
Loop
theFile.Close
vLine=split(ReadEntireFile,vbcrlf)
Dim f, f1, fc
Set f = fso.GetFolder(".")
Set fc = f.SubFolders
For Each f1 in fc
f1.name=vLine(i)
i=i+1
Next
保存为vbs后缀双击
20180427追加
谢谢明月的提醒,删除了两行无用代码。
#17
Dim fso, theFile, ReadEntireFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(fso.GetFolder(".").Path & "\标题.txt", 1, False)
Do While theFile.AtEndOfStream <> True
ReadEntireFile = ReadEntireFile & theFile.ReadLine & vbcrlf
Loop
theFile.Close
vLine=split(ReadEntireFile,vbcrlf)
Dim f, f1, fc, s,i
Set f = fso.GetFolder(".")
Set fc = f.SubFolders
For Each f1 in fc
ShowFolderList = ShowFolderList & f1.name & vbcrlf
f1.name=vLine(i)
i=i+1
Next
Dim strRoot As String '初始路径
Dim strOldName As String
Dim colOldNames As New Collection '旧路径名集合
Dim colNewNames As New Collection '准备修改的新路径名集合
Dim i As Integer
'获取旧路径名序列
strOldName = Dir(strRoot, vbDirectory)
Do While strOldName <> ""
If strOldName <> "." And strOldName <> ".." And (GetAttr(strRoot & strOldName) And vbDirectory) = vbDirectory Then
colOldNames.Add strOldName
End If
strOldName = Dir(, vbDirectory)
Loop
'替换文件夹名
'这里假设已存在的路径名序列数量小于等于你文本文件中的数据行数,否则报错
For i = 1 To colOldNames.Count
Name strRoot & colOldNames(i) As strRoot & colNewNames(i)
Next
结贴吧
#9
Dim strRoot As String '初始路径
Dim strOldName As String
Dim colOldNames As New Collection '旧路径名集合
Dim colNewNames As New Collection '准备修改的新路径名集合
Dim i As Integer
'获取旧路径名序列
strOldName = Dir(strRoot, vbDirectory)
Do While strOldName <> ""
If strOldName <> "." And strOldName <> ".." And (GetAttr(strRoot & strOldName) And vbDirectory) = vbDirectory Then
colOldNames.Add strOldName
End If
strOldName = Dir(, vbDirectory)
Loop
'替换文件夹名
'这里假设已存在的路径名序列数量小于等于你文本文件中的数据行数,否则报错
For i = 1 To colOldNames.Count
Name strRoot & colOldNames(i) As strRoot & colNewNames(i)
Next
结贴吧
完全菜鸟 不会用 保存为.VBS 打开提示语句为结束
#10
得了.最好手把手把你电脑上的都改好算了....
#11
靠!!不早说要VBS
#12
都懒得再写了,你纠结两天的时间,手工挨个也改完了
#13
熟悉一下for在批处理中的使用。
C:\>
for /? 对一组文件中的每一个文件执行某个特定命令。
FOR %variable IN (set) DO command [command-parameters]
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
或者,如果有 usebackq 选项:
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
Dim fso, theFile, ReadEntireFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(fso.GetFolder(".").Path & "\标题.txt", 1, False)
Do While theFile.AtEndOfStream <> True
ReadEntireFile = ReadEntireFile & theFile.ReadLine & vbcrlf
Loop
theFile.Close
vLine=split(ReadEntireFile,vbcrlf)
Dim f, f1, fc
Set f = fso.GetFolder(".")
Set fc = f.SubFolders
For Each f1 in fc
f1.name=vLine(i)
i=i+1
Next
保存为vbs后缀双击
20180427追加
谢谢明月的提醒,删除了两行无用代码。
#17
Dim fso, theFile, ReadEntireFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile(fso.GetFolder(".").Path & "\标题.txt", 1, False)
Do While theFile.AtEndOfStream <> True
ReadEntireFile = ReadEntireFile & theFile.ReadLine & vbcrlf
Loop
theFile.Close
vLine=split(ReadEntireFile,vbcrlf)
Dim f, f1, fc, s,i
Set f = fso.GetFolder(".")
Set fc = f.SubFolders
For Each f1 in fc
ShowFolderList = ShowFolderList & f1.name & vbcrlf
f1.name=vLine(i)
i=i+1
Next