Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 文件重命名键将第一个下划线改为下一个句点_Powershell - Fatal编程技术网

Powershell 文件重命名键将第一个下划线改为下一个句点

Powershell 文件重命名键将第一个下划线改为下一个句点,powershell,Powershell,如何筛选第一个下划线和下一个句点 这是我到目前为止收到的文件,但我收到的文件正在更改,在某些情况下,原始文件名有一个额外的下划线。我需要一个解释的方法 Get-ChildItem "\\MyFileServer\*" | Rename-Item -NewName { ($_.Name -replace '(?<=^.{3}).{5}', '.').Replace(".vfmpclmadj.", ".sa.") } 新文件名 9

如何筛选第一个下划线和下一个句点

这是我到目前为止收到的文件,但我收到的文件正在更改,在某些情况下,原始文件名有一个额外的下划线。我需要一个解释的方法

Get-ChildItem "\\MyFileServer\*" | Rename-Item -NewName { ($_.Name -replace '(?<=^.{3}).{5}', '.').Replace(".vfmpclmadj.", ".sa.") } 
新文件名

999.44444.sa.000025001.20201216.175314

这样的办法应该行得通

('999_987895_888888_544P.44444.vfmpclmadj.000025001.20201216.175314' -replace '_.+?(?=\.)').Replace(".vfmpclmadj.", ".sa.")
它只是查找下划线加上任何字符(最多一个句点)。你可以让它更严格,但对于这个例子来说,它是不需要的。类似的东西也可以,但只能在第一个下划线上。前者可能会影响字符串后面的其他下划线

('999_987895_888888_544P.44444.vfmpclmadj.000025001.20201216.175314' -replace '(?<=^[^_]+)_.+?(?=\.)').Replace(".vfmpclmadj.", ".sa.")
('999_987895_88888_544P.44444.vfmpclmadj.000025001.20201216.175314'-替换')?
('999_987895_888888_544P.44444.vfmpclmadj.000025001.20201216.175314' -replace '(?<=^[^_]+)_.+?(?=\.)').Replace(".vfmpclmadj.", ".sa.")