Page 1 of 1

Help iterating through folders to update a file

Posted: 12 Mar 2024 04:54
by aldomontoya
Hi, I've spent a few hours trying to search up how to do this but I just can't seem to get my structure right...

I'm trying to change a value in an ini file to an argument in the batch command. I have this working for a file in the same directory as the batch file, but I have hundreds of folders that I need to do this for. How can I adapt the script below to iterate through the folders in the path this file is run from?

Code: Select all

@echo off
rem to change Clone Hero Charter (in song.ini files)
setlocal EnableDelayedExpansion

rename song.ini song_org.ini

rem Define new values of desired variables - note if you need more than 5 add %x to the line below
set newValue[charter]=%1 %2 %3 %4 %5


(for /F "tokens=1,2 delims==" %%a in (song_org.ini) do (
   set "value=%%b"
   if defined newValue[%%a] set value=!newValue[%%a]!
   echo %%a=!value!
)) > song.ini
Appreciate the help!!! Thank you.