使用反向引用和日期时间戳重命名文件

时间:2017-03-23 19:24:19

标签: powershell rename backreference

我无法解决这个问题:

Missing newline: Unexpected character 0x20 found at location 4194303  

输出 20170323.0329-.txt ,我想要的输出为 20170323.0329-foo.txt 。我以前做过反向引用,但没有使用重命名项,我无法使用它。

2 个答案:

答案 0 :(得分:2)

需要正则表达式。只需使用格式字符串

Get-Item 'foo.txt' | Rename-Item -NewName {('{0:yyyyMMdd.hhmm}-{1}' -f (Get-Date), $_.BaseName)}

答案 1 :(得分:0)

就这样做

var f=function foo()
{
console.log("hello");
};

f();
foo();