https://github.com/vaishnavi502/find-replace
Powershell script that finds specific words in a text file and replaces them in a word document
https://github.com/vaishnavi502/find-replace
automated-change document-manipulation docx-file find-and-replace ms-word powershell ps1-script ps2exe windows-powershell word
Last synced: 3 months ago
JSON representation
Powershell script that finds specific words in a text file and replaces them in a word document
- Host: GitHub
- URL: https://github.com/vaishnavi502/find-replace
- Owner: Vaishnavi502
- Created: 2023-06-07T11:33:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-07T12:11:59.000Z (about 2 years ago)
- Last Synced: 2025-01-15T22:42:36.493Z (5 months ago)
- Topics: automated-change, document-manipulation, docx-file, find-and-replace, ms-word, powershell, ps1-script, ps2exe, windows-powershell, word
- Language: PowerShell
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Find-Replace for specific words
## Powershell script that finds specific words in a text file and replaces them in an MS word document### Target group
- Editors and writers
- Purpose: To replace commonly used phrases and words without needing to find and replace using MS Word's built-in function every time
- Automated replacement of words in British English to American English or vice-versa is useful through this
- Replacement of non-hyphenated words, use of en-dash or em-dash for certain commonly-used phrases is possible through this### About find.txt:
* A new phrase should be of the form: {old word(s)}:{new word(s)}
* Note: There shouldn't be any space after the colon unless you want an extra space upon replacement
* All occurrences of the words will be replaced in the word doc### Prerequisites:
- Powershell script must be allowed to run as per execution policy
- Check that your policy is either RemoteSigned, AllSigned or Bypass
In case it is not, open Windows powershell using Run as Administrator and using
```powershell
Get-ExecutionPolicy
Set-ExecutionPolicy -ExecutionPolicy
```
- The doc file you want to modify must be closed before running findrep.exe### Steps to follow before running findrep.exe:
1. Open findrep.ps1
2. Find the line
```powershell
$words=Get-Content C:\Users\DELL\Desktop\find.txt
```

and replace the path with path to your find.txt
```powershell
$words=Get-Content \find.txt
```
3. Now open Windows powershell and install the module ps2exe which will convert the findrep.ps1 to an .exe file

4. After installing ps2exe, you can now invoke it to convert findrep.ps1 to .exe:

5. Now double-click findrep.exe and you will be asked the file name in the cmd of the MS Word doc that you want to modify:

Provide the path to the word document you want to modify
6. Everytime changes are made to findrep.ps1 you will need to re-create the .exe file using ps2exe