cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
lala
Level VII

想通过脚本来获取指定路径的各个文件创建日期、只能通过循环来实现吗?

大家好!

这个代码能一次性获取指定路径的全部文件名列表

2022-03-06_15-44-04.png

 

如果想同时获取这个路径的各文件的创建日期、是否也能一次性获得。

但看到这个示例、好象只能通过循环才能实现?谢谢!

2022-03-06_15-43-01.png

 

4 REPLIES 4
jthi
Super User

Re: 想通过脚本来获取指定路径的各个文件创建日期、只能通过循环来实现吗?

With JSL (to my knowledge) you will have to loop over the file list you get from Files In Directory. You could also Run Program to get the names and creation dates at the same time by using cmd.exe or powershell.

 

Edit:

You might be able to use Multiple File Import to get the creation dates inside a directory. Take a look @Craige_Hales blog post  Directory Tree: Explore Space Used by Folders 

-Jarmo
lala
Level VII

Re: 想通过脚本来获取指定路径的各个文件创建日期、只能通过循环来实现吗?

非常感谢!

 

我的目的是想得到这个路径中创建日期最新的那个文件名。

frank_wang
Level IV

Re: 想通过脚本来获取指定路径的各个文件创建日期、只能通过循环来实现吗?

你可以尝试使用Files In Directory,然后打开 N items中最后的一个试试。在我的印象中,文件的排序是按照时间的。希望能帮助到你。

心若止水
lwx228
Level VIII

Re: 想通过脚本来获取指定路径的各个文件创建日期、只能通过循环来实现吗?

PS C:\Users\Administrator> (dir|where {$_.Mode -like "*a*"}|Sort-Object LastWriteTime -Descending).name[0]