🔒 Closed Rename files using Powershell

Status
Not open for further replies.

jaw2lag

Established
Sa mga gustong matoto pagrename ng mga files sa loog ng current folder heto ang Powershell command to the rescue.

Code:
powershell -C "gci | % {rni $_.Name ($_.Name -replace 'old-string', 'new-string')}"

Explanation:
--------------------------------------------
Code:
powershell -C "..."
- launches a PowerShell session to run the quoted command.
Code:
-C
- is short for -Command.
Code:
gci
- returns all the files in the current directory. It is an alias for Get-ChildItem.
Code:
| % {...}
- makes a pipeline to process each file. % is an alias for Foreach-Object.
Code:
$_.Name
- is the name of the current file in the pipeline.
Code:
($_.Name -replace 'old-string', 'new-string')
- uses the -replace operator to create the new file name. Each occurrence of the "old-string" is replaced with the "new-string".
Code:
rni
- changes the name of each file. The first parameter (called -Path) identifies the file. The second parameter (called -NewName) specifies the new name. rni is an alias for Rename-Item.
 
misleading yung prefix dapat "Tutorials" maraming salamat pa rin sa share mo sir malaking tulong pa rin to sa mga gusto rin magtago ng bold sa file nila 😆
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 4
    Replies
  • 639
    Views
  • 3
    Participants
Last reply from:
k4m0t3QT

Trending Topics

Online now

Members online
845
Guests online
3,961
Total visitors
4,806

Forum statistics

Threads
2,304,606
Posts
29,160,823
Members
1,196,868
Latest member
WitcherGayralt231
Back
Top