Run Script for all Config Files in a Directory

I need to run the following script on all inSync.cfg files under a directory called c:\inSync4\users.

powershell -Command “(get-content inSync.cfg) -replace ‘SYSTEM_PROXY = False’, ‘SYSTEM_PROXY = True’| set-content inSync.cfg”

So you want someone to create an action script that performs this action?

Questions about looping come up frequently. While actionscript doesn’t support true loops, there is a way to emulate looping by using lists.

If I understand your question correctly -

  1. There is a folder c:\inSync4\users
  2. Beneath this folder there are some number of folders, named for each User
  3. Beneath each user folder, there may or may not be a file ‘inSync.cfg’

You can try something like:

delete __appendfile

// Build the list of Powershell commands, concatenated with CR/LF characters to put each on a separate line
// The Powershell.exe command & static parameters are treated as string literals
// The pathname of the config files are substituted for ‘it’

appendfile {concatenation “%0d%0a” of (“powershell -Command %22(get-content %22” & it & “%22) -replace ‘SYSTEM_PROXY = False’, ‘SYSTEM_PROXY = True’| set-content %22” & it & “%22”) of pathnames of files “inSync.cfg” of folders of folders “c:\inSync4\Users”}

delete UpdateInSync.cmd

move __appendfile UpdateInSync.cmd

waithidden cmd /c UpdateInSync.cmd

1 Like

Thank you Jason. This is perfect.