Forum Discussion
I need help with PowerShell/ saving document files
- CaslynRose96Feb 17, 2022Copper Contributor
After I save the files, I save them into a separate folder from where they'll eventually end up, so I can apply to the powershell code to specific files. After I save, the files display as:
Next I insert the code to PowerShell that I found online somewhere.
I insert CA to be replaced, but I still need CA in the file name, So I make sure to put CA back into what will be replacing CA.
The code I use, I found online somewhere.
dir | rename-item -NewName {$_.name -replace " ","_"}
After I press enter It looks like this^^ Sometimes I will get an error with a bunch of red letters, but that is because it is informing that it was unable to apply code to some files or folders, because they don't have the CA data to replace. Any who, I got this far and the results look like this.
I want to add commas after the last name, because that is how my work needs files saved.
I could Avoid the whole coding thing entirely if Word could somehow retain my headers that have commas, and extend the length of text when saving.
This is how I have been doing my documents-->
This is how I have been creating my header, when I try to do single merge fields as header, Word doesn't retain all the text when saving. So I use greeting line. I have tried Inserting a comma after the last name within the recipient list, and the comma itself, no matter where it, manually or from the data source, word still doesn't see anything from the point of where the comma is inserted and everything after it.
Ill finish my steps to better explain what I mean.
I change the format so It isn't noticeable when saving, I change the font color to white and font size to be smaller.
After I create the greeting line, and uncheck names who don't need a document in saved It...
It opens in a new document,
I go to view > Outline > Then highlight all the content from where the header is, all the way down to the last person from my recipient list. The heading text is not visible (as I changed the color to white) but its there for saving purposes. AFTER I highlight all the content, I select Show Document > Create > File > Save as > Okay.
Then this is how it saves each individual file, with the last name first name and group name.
I use the code from the beginning to insert date to each file.
At first I tried to find a code that would recognize the specific lines the contain the first inserted merge fields with last name, first name, group, but I use the first names throughout the document, which makes think another obstacle. If I knew how to code, and had time to learn right now I would attempt creating it.
Any alternative ideas or suggestions would be greatly APPRECIATED! :))
Thank you for replying!
- Feb 17, 2022
- CaslynRose96Feb 17, 2022Copper Contributor
Sorry, haha well, if anyone ever comes across this, I can possibly help others with the same issue 🙂
But almost, I want the file names to look like
Dirt, Joe CA 02.17.22
Having the comma inserted after the last name. Joe is the first name