我已使用此代码从上一个答案中更改了mp4上的创建日期,但在输入日期时却收到错误消息:
$movFiles = Get-ChildItem "C:\Users\Neil\Pictures\Fishing" -Filter *.MP4
Foreach ($file in $movFiles)
{
$fileName = $file.Name
$userDate = Read-Host -Prompt "Date wanted for ${fileName} (format--> 13-02-1970) "
$newDateObj = Get-Date -Date userDate
$file.CreationTime = $newDateObj
}
“ 429V设置步骤游泳2011年8月27日Red Water.mp4”的日期(格式-> 13-02-1970): 2011年8月27日。输入日期,但出现此错误:
Get-Date : Cannot bind parameter 'Date'. Cannot convert value "userDate" to type "System.DateTime". Error: "The string
was not recognized as a valid DateTime. There is an unknown word starting at index 0."
At line:5 char:30
+ $newDateObj = Get-Date -Date userDate $file.CreationTime = $newDateOb ...
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-Date], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetDateCommand