LoginSignup
1
0

f

Posted at

@echo off
setlocal enabledelayedexpansion

set "directory=path\to\your\excel\files"
set "old_str=A"
set "new_str=B"

for /r "%directory%" %%f in (.xlsx) do (
powershell -Command "$excel = New-Object -ComObject Excel.Application; $workbook = $excel.Workbooks.Open('%%f'); foreach ($sheet in $workbook.Sheets) { foreach ($cell in $sheet.UsedRange.Cells) { if ($cell.Value2 -ne $null -and $cell.Value2 -is [String] -and $cell.Value2 -like '
%old_str%*') { $cell.Value2 = $cell.Value2 -replace '%old_str%', '%new_str%' } } }; $workbook.Save(); $excel.Quit();"
)

echo Batch replacement completed.

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0