Skip to content

Commit d377b75

Browse files
sethvsjuanpablojofre
authored andcommitted
Making Example 4 more precise.
1 parent 51d36a1 commit d377b75

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

reference/3.0/Microsoft.PowerShell.Management/Rename-Item.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ This command uses the Rename-Item cmdlet to rename a registry key from Advertisi
7171
When the command is complete, the key is renamed, but the registry entries in the key are unchanged.
7272
### Example 4
7373
```
74-
PS C:\> get-childItem *.txt | rename-item -newname { $_.name -replace '\.txt','.log' }
74+
PS C:\> get-childItem *.txt | rename-item -newname { $_.name -replace '\.txt$','.log' }
7575
```
7676

7777
This example shows how to use the Replace operator to rename multiple files, even though the NewName parameter does not accept wildcard characters.
@@ -91,6 +91,8 @@ Because the Replace operator works with regular expressions, the dot preceding "
9191
To ensure that it matches only a dot (.), it is escaped with a backslash character (\\).
9292
The backslash character is not required in ".log" because it is a string, not a regular expression.
9393

94+
To make sure that .txt is an extension, i.e. last part of the string representing the name, a dollar sign ($) is added after \\.txt.
95+
9496
### Example 5
9597
```
9698
Get-ChildItem -Filter "*.MARKUP" -Recurse | Rename-Item -NewName {"2017-01-10-" + $_.name}

0 commit comments

Comments
 (0)