Tinus EngOps Wiki

Logo

OpsaC - Operating as PowerShell code

Links

Home

IT-Wiki

PowerShell Blog

PowerShell Index

PowerShell Search

Additional Websites

View my GitHub Profile

View my GitHub Gists

View my Codeberg Page

View my Photo Website

File/Folder umbenennen

published: February 10, 2016 author: Tinu tags: Scripting categories: PowerShell


Mehrere Files/Folder umbenennen

Get-ChildItem | %{Rename-Item -Path $_.FullName -NewName "Prefix_$($_.Name)"}
$searchstr  = 'old'
$replacestr = 'new'
$entrydir   = 'Z:\06_Puppet\sciiswebadministration'
gci $entrydir -Recurse | Where Name -Like -Value $searchstr | % {
    $newname = $_.name.replace($searchstr, $replacestr)
    Rename-Item $_.fullname $newname
}

Ausdruck in mehrerern Files ersetzten

$searchstr  = 'old'
$replacestr = 'new'
$entrydir   = 'Z:\Temp'

gci $entrydir -Recurse | % {
    if(!($_.PsIsContainer))
    {
        if(gc -Path $_.FullName | Select-String -Pattern $searchstr)        
        {
            "$($searchstr) -> $($_.FullName)"
            (gc $_.FullName) -replace $searchstr, $replacestr | sc $_.FullName
        }
    }
}

← Previous Post ◇ [ Top ] ◇ Copyright © 2024 by tinuwalther ◇ [ Blog ] ◇ Next Post →