DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: SOLVED: Easy use of a variable to edit a php (text) file in a batch file  (Read 8,202 times)

questorfla

  • Fighting Slime all the Time
  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
Not sure where I am missing something . It may be that editing a .php" file doesn't the same rules as a .txt file but i am using a text editor to modify manually.
the file "config.php" need for line 3 which states :  $directory  = "directory";  .  to change the word in quotes to the value of %inputb%.  Once that is done, the config.php file is used to continue to creation of the folder.  That's about it. 
The prior operations would have loaded the correct value for the name "directory" into the variable %inputb%  I know inputb has the correct data in it as I can print it on screen with echo but I cannot get it to edit the config.php file as shown without exiting the batch which was the whole point in doing it :(
so that after building the layout it ends with that file modified to reflect the value of the variable at the time it was loaded.
The php file has 54 lines total and i only need to add the name of the directory in line 3.  I cant just use the variable itself because of other scripts that would use the same config file that would not provide the information for %inputb%

questorfla

  • Fighting Slime all the Time
  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
Whoops.  Sorry Skwire.  I may be in the wrong forum.

questorfla

  • Fighting Slime all the Time
  • Supporting Member
  • Joined in 2012
  • **
  • Posts: 570
http://www.dostips.com/?t=Batch.FindAndReplace
>>Excellent bit of craftsmanship! <
Whew!  Finally found the answer and it even worked!  I just did not look hard enough. 

Skwire, can you please remove this whole thread or post somewhere if it might be of use to others.
Thanks
(I regret to say i do not know how to close or move one :(  )

Original address: https://www.donationcoder.com/forum/index.php?topic=39548.0