Python Forum

Full Version: Find string and add character - newbi
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am in the process of learning Python. Now I have a concrete challenge I would like to give my self. Once in a while I need to do some changes in a VB-script txt file. I would like to automate those tasks – and here I need your help. Can you help me figure out how to complete the tasks or send me hints or links for what functions to look for. Thank you a lot in advance for taking time ?

This is what I think should be automated:

1. Open the txt file
2. Find these to sentences and insert a “’” in front of the text (to outcomment in VB)
If bStatus Then bStatus=File_ExistFile(gsCommonDesktop & "\Google Chrome.lnk",False)
If bStatus and gbValue=True Then bStatus = File_DelFile(gsCommonDesktop & "\Google Chrome.lnk",TRUE)
3. Find this sentence and change the very last number (1) to the number zero (0)
4. Save the file.
What have you tried? We're not big on writing code for people here, but we would be happy to help you fix your code when you run into problems. When you do run into problems, please post your code in Python tags, and clearly explain the problem you are having, including the full text of any errors.