拖拽文件夹到 BAT,文件清单自动生成 Excel(附完整脚本)
把一整个文件夹的文件名整理成表格,不用手动复制,拖一下就行
写在前面
做标签批量打印时,经常会遇到这种情况:文件夹里躺着几百个 PDF 或图片,软件需要一份记录文件名的表格来连接数据库。手动一个个复制文件名到 Excel,费时还容易漏行、串行。
这个小工具就是用来解决这件事的:扫描指定文件夹,把全部文件名按顺序整理成一份 文件清单.xlsx,不需要安装 Office,也不依赖任何第三方库,双击或拖拽文件夹即可运行。
01 这个工具能做什么
-
• 扫描文件夹内的文件,可限定格式(只扫 PDF、只扫图片,或全部文件);
-
• 按文件名自然排序:
2-1排在10-1前面,不会出现数字乱序; -
• 直接生成
.xlsx表格,A 列表头为「文件名称」,一行一个文件名; -
• 不依赖 Office 或第三方组件,系统自带 PowerShell 即可运行;
-
• 表格正被 Excel 占用时,自动另存为带时间戳的新文件,不会丢数据;
-
• 万一 xlsx 打包失败,会退一步导出 CSV,Excel 同样可以直接打开。
02 使用方法:把文件夹拖到 BAT 窗口
最简单的用法是拖拽运行:
-
1. 准备好要扫描的文件夹(本例为存放 PDF 的目录);
-
2. 用鼠标把这个文件夹直接拖到
文件清单生成 [Excel.bat](http://Excel.bat)文件图标上(也可以拖到已经打开的 BAT 黑色窗口里); -
3. 松开鼠标,脚本自动以该文件夹为扫描目录开始运行;
-
4. 命令行窗口会依次显示:扫描目录、扫描格式、文件数量、第一个文件、最后一个文件,以及生成的清单路径;
-
5. 看到「已生成」提示后,按任意键关闭窗口,清单表格就在脚本所在目录。
另一种方式是双击运行:把 BAT 放到要扫描的文件夹里双击,脚本默认扫描脚本所在目录;需要换目录时,直接拖文件夹进来即可。
图1 运行完成后,命令行显示扫描目录、文件数量和输出文件位置
本例扫描目录内共 11 个文件,清单第一行为 [1.png](http://1.png) ,最后一行为 [11.png](http://11.png) ,与实际文件一一对应。
03 配置区:常用选项改这里
脚本开头有一段配置区,不需要改逻辑,只改对应的值即可适配不同场景:
| 配置项 | 作用 | 默认值 |
|---|---|---|
$FileExtensions |
扫描哪些格式;@() 为全部文件,可填 @('pdf')、@('jpg','jpeg') 等 |
@() |
$SubFolderName |
扫描哪个文件夹;留空扫脚本所在目录,也可写相对或绝对路径 | '' |
$IncludeSubDirs |
是否连子文件夹一起扫 | $false |
$HeaderText |
A1 表头文字 | 文件名称 |
$OutputFileName |
输出表格文件名 | 文件清单.xlsx |
$ExcludeNames |
额外要排除的文件名(脚本自身和输出文件已自动排除) | @() |
脚本自身和本次输出的清单文件会被自动排除,不会把自己列进表格。
04 完整脚本代码
下面是 文件清单生成 [Excel.bat](http://Excel.bat) 的完整内容,需要的可以自行复制保存为 .bat 文件使用;脚本内部调用系统 PowerShell 完成扫描与打包,无需额外安装组件。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
@echo off
chcp 65001 >nul 2>&1
setlocal EnableExtensions
title File list to Excel
set "SELF=%~f0"
set "TARGETARG=%~1"
set "PSEXE=%SystemRoot%\System32\WindowsPowerShell\
[v1.0\powershell.exe"](http://v1.0\powershell.exe)
if not exist "%PSEXE%" set "PSEXE=
[powershell.exe"](http://powershell.exe)
echo.
echo Scanning files, building Excel list ...
echo.
"%PSEXE%" -NoProfile -ExecutionPolicy Bypass -Command "& { $s=[
[IO.File]::ReadAllText($env:SELF);](http://IO.File]::ReadAllText%28$env:SELF%29;) $m='##'+'PS##'; $i=$
[s.IndexOf($m);](http://s.IndexOf%28$m%29;) if ($i -lt 0) { Write-Host 'internal block not found' -ForegroundColor Red; exit 1 }; Invoke-Expression $
[s.Substring($i](http://s.Substring%28$i) + 6) }"
echo.
pause
exit /b
##PS##
# ==================== 配置区(要改就改这里) ====================
#
# 【1】扫描哪些格式 —— 默认扫全部文件
# 可写多个,不区分大小写,不用带前面的点
# 扫全部文件(不限格式): @() <- 默认
# 只扫 PDF : @('pdf')
# 改成只扫 JPG : @('jpg')
# JPG(含 jpeg)一起扫 : @('jpg','jpeg')
# 常见图片全扫 : @('jpg','jpeg','png','bmp','gif','webp','tif')
# PDF + JPG 一起扫 : @('pdf','jpg')
$FileExtensions = @()
#
# 【2】扫描哪个文件夹
# 留 '' :直接扫脚本所在目录(默认,最通用:脚本放哪个文件夹就扫哪个)
# 留 'PDF':先找脚本同目录下的 PDF 文件夹,没有就找与第一个格式同名的文件夹(如 JPG),
# 再没有才扫脚本所在目录
# 也可写相对或绝对路径,例如 'D:\资料\扫描件'
$SubFolderName = ''
#
# 【3】是否连子文件夹一起扫
$IncludeSubDirs = $false
#
# 【4】A1 表头文字
# 留 '' :自动生成,单格式=pdf / jpg;多格式=pdf+jpg;全部文件=all
$HeaderText = '文件名称'
#
# 【5】输出文件名
# 留 '' :自动生成,如 全部文件清单.xlsx、pdf文件清单.xlsx
$OutputFileName = '文件清单.xlsx'
#
# 【6】额外要排除的文件名(可留空)
# 脚本自身和本次输出文件已自动排除,不用写在这里
# 例:@('说明.txt','目录清单.docx')
$ExcludeNames = @()
#
# ================================================================
$ErrorActionPreference = 'Stop'
# 把文字处理成合法 XML 文本
function Xml-SafeText([string]$value) {
if ([string]::IsNullOrEmpty($value)) { return '' }
$v = [regex]::Replace($value, '[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]', '')
$v = $
[v.Replace('&',](http://v.Replace%28'&',) '&').Replace('<', '<').Replace('>', '>')
return $v
}
# 自然排序:数字段补零,让 2-1 排在 10-1 前面
$script:PadEvaluator = [
[System.Text.RegularExpressions.MatchEvaluator]](http://System.Text.RegularExpressions.MatchEvaluator]) { param($m) $
[m.Value.PadLeft(12,](http://m.Value.PadLeft%2812,) '0') }
function Get-NaturalKey([string]$name) {
return [regex]::Replace($
[name.ToLowerInvariant(),](http://name.ToLowerInvariant%28%29,) '\d+', $script:PadEvaluator)
}
# 直接按 OOXML 结构打包 xlsx,不依赖 Office / 任何第三方库
function Write-XlsxFile([string]$path, $parts) {
Add-Type -AssemblyName [System.IO.Compression](http://System.IO.Compression) -ErrorAction SilentlyContinue | Out-Null
Add-Type -AssemblyName [System.IO.Compression.FileSystem](http://System.IO.Compression.FileSystem) -ErrorAction SilentlyContinue | Out-Null
$fs = [
[System.IO.File]::Open($path,](http://System.IO.File]::Open%28$path,) [
[System.IO.FileMode]::Create,](http://System.IO.FileMode]::Create,) [
[System.IO.FileAccess]::Write)](http://System.IO.FileAccess]::Write%29)
$zip = [
[System.IO.Compression.ZipArchive]::new($fs,](http://System.IO.Compression.ZipArchive]::new%28$fs,) [
[System.IO.Compression.ZipArchiveMode]::Create)](http://System.IO.Compression.ZipArchiveMode]::Create%29)
try {
$enc = [
[System.Text.UTF8Encoding]::new($false)](http://System.Text.UTF8Encoding]::new%28$false%29)
foreach ($key in $
[parts.Keys)](http://parts.Keys%29) {
$entry = $
[zip.CreateEntry([string]$key,](http://zip.CreateEntry%28[string]$key,) [
[System.IO.Compression.CompressionLevel]::Optimal)](http://System.IO.Compression.CompressionLevel]::Optimal%29)
$es = $
[entry.Open()](http://entry.Open%28%29)
$sw = [
[System.IO.StreamWriter]::new($es,](http://System.IO.StreamWriter]::new%28$es,) $enc)
try { $
[sw.Write([string]$parts[$key])](http://sw.Write%28[string]$parts[$key]%29) } finally { $
[sw.Dispose()](http://sw.Dispose%28%29) }
}
} finally {
$
[zip.Dispose()](http://zip.Dispose%28%29)
$
[fs.Dispose()](http://fs.Dispose%28%29)
}
}
# ---------------- 0. 整理配置 ----------------
$exts = @()
foreach ($item in @($FileExtensions)) {
$t = ([string]$item).Trim().TrimStart('.').ToLowerInvariant()
if ($t) { $exts += $t }
}
$extLabel = if ($
[exts.Count](http://exts.Count) -gt 0) { ($exts -join '+') } else { 'all' }
if ([string]::IsNullOrWhiteSpace($HeaderText)) { $HeaderText = $extLabel }
if ([string]::IsNullOrWhiteSpace($OutputFileName)) {
$prefix = if ($
[exts.Count](http://exts.Count) -gt 0) { ($exts -join '_') } else { '全部' }
$OutputFileName = $prefix + '文件清单.xlsx'
}
# ---------------- 1. 定位扫描文件夹 ----------------
$selfPath = $env:SELF
$baseDir = Split-Path -Parent $selfPath
$argFolder = $env:TARGETARG
$scanDir = $null
if (-not [string]::IsNullOrWhiteSpace($argFolder)) {
if (Test-Path -LiteralPath $argFolder -PathType Container) {
$scanDir = (Resolve-Path -LiteralPath $argFolder).Path
} elseif (Test-Path -LiteralPath $argFolder -PathType Leaf) {
$scanDir = Split-Path -Parent (Resolve-Path -LiteralPath $argFolder).Path
}
}
if (-not $scanDir) {
$candidates = @()
if (-not [string]::IsNullOrWhiteSpace($SubFolderName)) {
if ([
[System.IO.Path]::IsPathRooted($SubFolderName)](http://System.IO.Path]::IsPathRooted%28$SubFolderName%29) -or $SubFolderName -match '\\') {
$candidates += $SubFolderName
} else {
$candidates += (Join-Path $baseDir $SubFolderName)
if ($
[exts.Count](http://exts.Count) -gt 0) { $candidates += (Join-Path $baseDir $exts[0].ToUpperInvariant()) }
}
}
foreach ($c in $candidates) {
if (Test-Path -LiteralPath $c -PathType Container) {
$scanDir = (Resolve-Path -LiteralPath $c).Path
break
}
}
}
if (-not $scanDir) { $scanDir = $baseDir }
if (-not (Test-Path -LiteralPath $scanDir -PathType Container)) {
Write-Host ('找不到文件夹:' + $scanDir) -ForegroundColor Red
exit 1
}
Write-Host ('扫描目录 : ' + $scanDir) -ForegroundColor Cyan
Write-Host ('扫描格式 : ' + $extLabel) -ForegroundColor Cyan
# ---------------- 2. 收集并排序文件 ----------------
$allFiles = @(Get-ChildItem -LiteralPath $scanDir -File -Recurse:$IncludeSubDirs -ErrorAction SilentlyContinue)
if ($
[exts.Count](http://exts.Count) -gt 0) {
$matchedFiles = @($allFiles | Where-Object { $exts -contains $
[_.Extension.TrimStart('.').ToLowerInvariant()](http://_.Extension.TrimStart%28'.'%29.ToLowerInvariant%28%29) })
} else {
$matchedFiles = $allFiles # 不限格式
}
# 排除脚本自身、本次输出文件、自定义排除项,避免“全部扫描”时把自己列进表格
$excludeFull = @($selfPath)
if (-not [string]::IsNullOrWhiteSpace($OutputFileName)) {
$excludeFull += (Join-Path $baseDir $OutputFileName)
$excludeFull += (Join-Path $baseDir ([
[System.IO.Path]::GetFileNameWithoutExtension($OutputFileName)](http://System.IO.Path]::GetFileNameWithoutExtension%28$OutputFileName%29) + '.csv'))
}
foreach ($xn in @($ExcludeNames)) {
$n = ([string]$xn).Trim()
if ($n) { $excludeFull += (Join-Path $scanDir $n) }
}
$matchedFiles = @($matchedFiles | Where-Object { $excludeFull -notcontains $
[_.FullName](http://_.FullName) })
$sortedFiles = @($matchedFiles | Sort-Object @{ Expression = { Get-NaturalKey $
[_.Name](http://_.Name) } }, @{ Expression = { $
[_.Name](http://_.Name) } })
$names = @($sortedFiles | ForEach-Object { $
[_.Name](http://_.Name) })
# ---------------- 3. 生成工作表 XML ----------------
$lastRow = $
[names.Count](http://names.Count) + 1
if ($lastRow -lt 1) { $lastRow = 1 }
$sb = [
[System.Text.StringBuilder]::new()](http://System.Text.StringBuilder]::new%28%29)
[void]$
[sb.Append(' r="1">' + (Xml-SafeText $HeaderText) + '')](http://sb.Append%28'<row)
for ($i = 0; $i -lt $
[names.Count;](http://names.Count;) $i++) {
$r = $i + 2
[void]$
[sb.Append(' r="' + $r + '">' + (Xml-SafeText $names[$i]) + '')](http://sb.Append%28'<row)
}
$rowsXml = $
[sb.ToString()](http://sb.ToString%28%29)
$sheetXml = @(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
''"
target="_blank"
style="color: #576b95; text-decoration: none;">
['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> http://schemas.openxmlformats.org/spreadsheetml/2006/main">'](http://schemas.openxmlformats.org/spreadsheetml/2006/main)
('<dimension ref="A1:A' + $lastRow + '"/>')
'<sheetViews><sheetView tabSelected="1" workbookViewId="0"><pane ySplit="1" topLeftCell="A2" activePane="bottomLeft" state="frozen"/><selection pane="bottomLeft" activeCell="A2" sqref="A2"/></sheetView></sheetViews>'
'<sheetFormatPr defaultRowHeight="15"/>'
'<cols><col min="1" max="1" width="70" customWidth="1"/></cols>'
'<sheetData>'
$rowsXml
'</sheetData>'
'</worksheet>'
) -join ''
$stylesXml = @(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
''"
target="_blank"
style="color: #576b95; text-decoration: none;">
['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> http://schemas.openxmlformats.org/spreadsheetml/2006/main">'](http://schemas.openxmlformats.org/spreadsheetml/2006/main)
'<fonts count="2">'
'<font><sz val="11"/><color theme="1"/><name val="等线"/><family val="2"/><charset val="134"/></font>'
'<font><b/><sz val="11"/><color theme="1"/><name val="等线"/><family val="2"/><charset val="134"/></font>'
'</fonts>'
'<fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills>'
'<borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders>'
'<cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs>'
'<cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/></cellXfs>'
'<cellStyles count="1"><cellStyle name="常规" xfId="0" builtinId="0"/></cellStyles>'
'</styleSheet>'
) -join ''
$workbookXml = @(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
'
[http://schemas.openxmlformats.org/spreadsheetml/2006/main"](http://schemas.openxmlformats.org/spreadsheetml/2006/main)
xmlns:r="['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> http://schemas.openxmlformats.org/officeDocument/2006/relationships">'](http://schemas.openxmlformats.org/officeDocument/2006/relationships)
'<sheets><sheet name="文件列表" sheetId="1" r:id="rId1"/></sheets>'
'</workbook>'
) -join ''
$wbRels = @(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
''"
target="_blank"
style="color: #576b95; text-decoration: none;">
['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> http://schemas.openxmlformats.org/package/2006/relationships">'](http://schemas.openxmlformats.org/package/2006/relationships)
'
[http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"](http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet)
Target="worksheets/['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> sheet1.xml"/>'](http://sheet1.xml)
'
[http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"](http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles)
Target="['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> styles.xml"/>'](http://styles.xml)
'</Relationships>'
) -join ''
$rootRels = @(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
''"
target="_blank"
style="color: #576b95; text-decoration: none;">
['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> http://schemas.openxmlformats.org/package/2006/relationships">'](http://schemas.openxmlformats.org/package/2006/relationships)
'
[http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"](http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument)
Target="xl/['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> workbook.xml"/>'](http://workbook.xml)
'</Relationships>'
) -join ''
$contentTypes = @(
'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
''"
target="_blank"
style="color: #576b95; text-decoration: none;">
['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> http://schemas.openxmlformats.org/package/2006/content-types">'](http://schemas.openxmlformats.org/package/2006/content-types)
''"
target="_blank"
style="color: #576b95; text-decoration: none;">
['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> vnd.openxmlformats-package.relationships+xml"/>'](http://vnd.openxmlformats-package.relationships+xml)
'<Default Extension="xml" ContentType="application/xml"/>'
'
[workbook.xml"](http://workbook.xml)
ContentType="application/['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>'](http://vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml)
'
[sheet1.xml"](http://sheet1.xml)
ContentType="application/['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>'](http://vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml)
'
[styles.xml"](http://styles.xml)
ContentType="application/['" <br> target="_blank" <br> style="color: #576b95; text-decoration: none;"><br> vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'](http://vnd.openxmlformats-officedocument.spreadsheetml.styles+xml)
'</Types>'
) -join ''
$parts = [ordered]@{
'[Content_Types].xml' = $contentTypes
'_rels/.rels' = $rootRels
'xl/
[workbook.xml'](http://workbook.xml') = $workbookXml
'xl/_rels/
[workbook.xml.rels'](http://workbook.xml.rels') = $wbRels
'xl/worksheets/
[sheet1.xml'](http://sheet1.xml') = $sheetXml
'xl/
[styles.xml'](http://styles.xml') = $stylesXml
}
# ---------------- 4. 写出文件 ----------------
$outPath = Join-Path $baseDir $OutputFileName
$written = $false
try {
Write-XlsxFile $outPath $parts
$written = $true
} catch {
# 常见原因:表格正被 Excel 打开,另存为带时间戳的新文件
$stamp = Get-Date -Format 'yyyyMMdd_HHmmss'
$outPath = Join-Path $baseDir ([
[System.IO.Path]::GetFileNameWithoutExtension($OutputFileName)](http://System.IO.Path]::GetFileNameWithoutExtension%28$OutputFileName%29) + '_' + $stamp + '.xlsx')
try {
Write-XlsxFile $outPath $parts
$written = $true
Write-Host '原文件被占用(可能已用 Excel 打开),已另存为新文件。' -ForegroundColor Yellow
} catch {
Write-Host ('生成 Excel 失败:' + $
[_.Exception.Message)](http://_.Exception.Message%29) -ForegroundColor Red
}
}
# 万一 xlsx 打包失败,退一步导出 CSV(Excel 也能直接打开)
if (-not $written) {
$csvPath = Join-Path $baseDir ([
[System.IO.Path]::GetFileNameWithoutExtension($OutputFileName)](http://System.IO.Path]::GetFileNameWithoutExtension%28$OutputFileName%29) + '.csv')
$csvLines = @($HeaderText) + $names
$enc = [
[System.Text.UTF8Encoding]::new($true)](http://System.Text.UTF8Encoding]::new%28$true%29)
[
[System.IO.File]::WriteAllLines($csvPath,](http://System.IO.File]::WriteAllLines%28$csvPath,) $csvLines, $enc)
$outPath = $csvPath
}
# ---------------- 5. 结果提示 ----------------
Write-Host ''
Write-Host ('文件数量 : ' + $
[names.Count)](http://names.Count%29) -ForegroundColor Cyan
if ($
[names.Count](http://names.Count) -gt 0) {
Write-Host ('第一个 : ' + $names[0]) -ForegroundColor DarkGray
Write-Host ('最后一个 : ' + $names[$
[names.Count](http://names.Count) - 1]) -ForegroundColor DarkGray
} else {
Write-Host ('当前目录里没有找到 ' + $extLabel + ' 文件(表格仅保留表头)。') -ForegroundColor Yellow
}
Write-Host ('已生成 : ' + $outPath) -ForegroundColor Green
05 BAT 文件获取方式
如果不想手动复制代码,可以直接获取整理好的成品 BAT 文件:
关注公众号【素简好物】,后台回复关键词【文件清单生成】,即可领取 文件清单生成 [Excel.bat](http://Excel.bat) ,下载后按上面的拖拽方法使用即可。