本文介绍了用于识别子文件夹的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现这个脚本会创建一个excel表,其中包含特定目录中的所有文件夹和文件。

任何人都可以通过建议我如何编辑它以便它只报告来帮助我第1级子文件夹,其子文件夹的名称为5位数字?



我的目的是这样的,价格为


root folders = year ie:1986,2004,2012

在每年的文件夹中都有第1级子文件夹 这是用最后2年数字+项目命名的5位数项目文件夹#ie:86001,04001,12001

我需要在所有第1级子文件夹中搜索5位#s的文件夹假设是一级子文件夹,但在根文件和第一级文件夹被锁定之前错误地移动过去。(大约3000个第一级子文件夹)这是
我想要修改的代码。如果有人有更好的剧本,我会很高兴见到它。


objStartFolder =" M:\"

设置objExcel = CreateObject(" Excel.Applic ation")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

objExcel.Cells(1,1).Value =" Folder"

objExcel.Cells(1,2).Value =" File Name"

设置objFSO = CreateObject(" Scripting.Fi leSystemOb ject")

设置objFolder = objFSO.GetFolder(objStartF old)

设置colFiles = objFolder.Files

For colFiles中的每个objFile

objExcel.Cells(intRow,1).Value = objfolder.Name

objExcel.Cells(intRow,2).Value = objFile.Name

intRow = intRow + 1

下一页

ShowSubfolders objFSO .GetFolder(objStartF 旧版)

Sub ShowSubFolders(文件夹)

For Folder.SubFolders中的每个子文件夹

objExcel.Cells(intRow ,1).Value = Subfolder.Path

设置objFolder = objFSO.GetFolder(子文件夹 .Path)

设置colFiles = objFolder.Files

For colFiles中的每个objFile

objExcel.Cells(intRow,2).Value = objFile.Name

intRow = intRow + 1

下一个

ShowSubFolders子文件夹

下一页

结束子

objExcel.Range(" A1:B1")。Se lect

objExcel.Selection.Interio r.ColorInd ex = 19

objExcel.Selection.Font.Co lorIndex = 11

objExcel.Selection.Font.Bo ld = True

objExcel.Cells.EntireColum n.AutoFit

MsgBox" Done"                     

解决方案

I found this script that will create an excel sheet with all the folders and files in a specific dir.
Can anyone help me out by advising how I can edit it so that it will only report 1st level subfolders that have a subfolder with a 5 digit name??

My dir is like this

root folders = year ie: 1986, 2004,2012
In each year folder there 1st level subfolders  that are 5 digit project folders named with the last 2 year digits+the project # ie: 86001, 04001, 12001
I need to search all 1st level subfolders for folders with the 5 digit #s that are suppose to be a 1st level subfolder but have been moved in the past by mistake before the root and 1st level folders were locked down.(about 3000 1st level subfolders) Here is the code i am trying to modify. If anyone has a better script I would be very glad to see it

objStartFolder = "M:\"
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add
intRow = 2
objExcel.Cells(1, 1).Value = "Folder"
objExcel.Cells(1, 2).Value = "File Name"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
objExcel.Cells(intRow, 1).Value = objfolder.Name
objExcel.Cells(intRow, 2).Value = objFile.Name
intRow = intRow + 1
Next
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
objExcel.Cells(intRow, 1).Value = Subfolder.Path
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
objExcel.Cells(intRow, 2).Value = objFile.Name
intRow = intRow + 1
Next
ShowSubFolders Subfolder
Next
End Sub
objExcel.Range("A1:B1").Select
objExcel.Selection.Interior.ColorIndex = 19
objExcel.Selection.Font.ColorIndex = 11
objExcel.Selection.Font.Bold = True
objExcel.Cells.EntireColumn.AutoFit
MsgBox "Done"                    

解决方案


这篇关于用于识别子文件夹的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 23:34