フォルダ名と、ファイル内の文字を置換するワンライナー。bash, Power Shell
メモ
Contents
bash
フォルダ名
find . -type d -name "OLD" -exec bash -c 'mv "$1" "${1%/*}/NEW"' _ {} \;
ファイル内テキスト
find . -type f -exec sed -i 's/OLD/NEW/g' {} +
Power Shell
フォルダ名
Get-ChildItem -Path . -Directory -Recurse -Filter 'OLD' | ForEach-Object {
Move-Item $_.FullName ($_.FullName -replace 'OLD', 'NEW')
}
ファイル内テキスト
Get-ChildItem -Path . -Recurse -File | ForEach-Object {
$filePath = $_.FullName
(Get-Content $filePath) | ForEach-Object {
$_ -replace "OLD", "NEW"
} | Set-Content $filePath
}
ディスカッション
コメント一覧
まだ、コメントがありません