需要更改基于csv的文件创建日期 [英] need to change file created date based on csv
问题描述
大家晚上好.我已经能够使用以下命令$(Get-Item test1.html).CreationTime = $(Get-Date"11/24/2010 06:00 am")来更改文件的创建日期属性
Good evening everyone. I have been able to change date created attribute of a file using the following command $(Get-Item test1.html).CreationTime=$(Get-Date "11/24/2010 06:00 am")
我的问题是我有10000个文件,需要根据csv文件完成此操作.CSV具有两列文件名或文件创建日期.CSV和文件位于同一文件夹中.如何根据第2列中的相应日期重命名文件
My problem is that I have 10000 files that need to have this done based on a csv file. CSV has two columns file name or and file created date. CSV and files are in same folder. How can I rename the files based on the corresponding date in column 2
例如
1.pdf 2010/12/12
2.pdf 2011/13/01
3.pdf 1989/12/12
etc
先谢谢了.也许我可以使用Powershell来做到这一点我可以使用excel创建第3列以获取以下内容.在Powershell窗口中复制和粘贴无效
Thanks in advance. Perhaps I can use powershell to do this I can use excel to create 3rd column to get the following. Copy and paste in powershell window did not work
$(Get-Item 1.pdf).CreationTime=$(Get-Date "11/24/2010 06:00 am")
$(Get-Item 2.pdf).CreationTime=$(Get-Date "11/24/2009 06:00 am")
但是然后如何在Powershell中运行此文件.
but then how do I run this file in powershell.
推荐答案
假定您的csv文件具有2个标头:FileName&FileCreationTIme
assuming your csv file has 2 headers : FileName & FileCreationTIme
Import-Csv -Path 'pathtoyourcsvfile' |
ForEach-Object { (Get-Item $_.filename).CreationTime = (Get-date $_.filecreationTime) }
这篇关于需要更改基于csv的文件创建日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!