我目前在批处理文件中使用以下行来检索子目录中包含标题中单词“ complete”的pdf文件列表。
dir /b /s *COMPLETE*.PDF >Q:\"Personal Folders"\Advertising\"Data Updates"\ePrint\test.csv
有没有一种方法可以更改此设置,以将创建的日期附加到每个文件的开头,以便可以在Excel中按日期对它们进行排序?谢谢你。
使用以下批处理文件。
GetFileCreateDate.cmd:
@echo off
setlocal
for /f "tokens=*" %%f in ('dir /b /s "*COMPLETE*.PDF"') do (
for /f "tokens=1,2" %%g in ( 'dir "%%f" /tc ^| findstr /C: "%%~nxf"') do (
echo %%g,%%h,"%%f"
)
)>>Q:\"Personal Folders"\Advertising\"Data Updates"\ePrint\test.csv
endlocal
笔记:
输出行将具有以下格式:
create_date,create_time,"filename"
filename
文件的绝对名称在哪里
修改echo %%g,%%h,"%%f"
以适合您要在csv文件中使用的格式。
%%g
是create_date,%%h
是create_time,并且%%f
是绝对文件名。
输出示例(仅写入“ test.csv”):
F:\test>dir /b /s "*COMPLETE*.PDF"
F:\test\1complete1.pdf
F:\test\2complete2.pdf
F:\test\complete1.pdf
F:\test\complete2(s).pdf
F:\test>GetFileCreateDate.cmd
F:\test>type test.csv
26/08/2016,21:28,"F:\test\1complete1.pdf"
26/08/2016,21:28,"F:\test\2complete2.pdf"
26/08/2016,21:28,"F:\test\complete1.pdf"
26/08/2016,21:28,"F:\test\complete2(s).pdf"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句