PowerShell - How to put the following script together + adjust Header and Footer
Here is a sample of the script for Word Document that I am working on it at the moment
The script changes a word in all of the files, but **** does not **** change part of the file name and Header and Footer
$objWord = New-Object -comobject Word.Application
$objWord.Visible = $false
$list = Get-ChildItem "C:Users*.*" -Include *.doc*
foreach($item in $list){
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
}
$objWord.Quit()
Heres the scrip to change a part of the file name :
PS C:User> get-childitem | foreach { rename-item $_ $_.Name.Replace("file1", "computer") }
How can I put everything together ?
Thanks
powershell scripting
add a comment |
Here is a sample of the script for Word Document that I am working on it at the moment
The script changes a word in all of the files, but **** does not **** change part of the file name and Header and Footer
$objWord = New-Object -comobject Word.Application
$objWord.Visible = $false
$list = Get-ChildItem "C:Users*.*" -Include *.doc*
foreach($item in $list){
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
}
$objWord.Quit()
Heres the scrip to change a part of the file name :
PS C:User> get-childitem | foreach { rename-item $_ $_.Name.Replace("file1", "computer") }
How can I put everything together ?
Thanks
powershell scripting
1
There is nothing in your word code that addresses you header footer needs. Changing the file name or part of the file name is a common practice, with examples in the help files and all over the web and on this site. stackoverflow.com/questions/24887905/…, your rename command is static, but you say you are hitting multiple files. Are you say, all files, contain the word file1, and you are trying to replace the files1 with the word computer? That comes off as all files are name the same, which is not a thing.
– postanote
Nov 22 '18 at 3:32
I was wondering if theres a way to combine all of it. I do understand that the code does not address header and footer. Wondering If someone could help
– user91
Nov 26 '18 at 12:22
@postanote stackoverflow.com/questions/46041100/… this is what I was talking about, but I tried to add this code : get-childitem |foreach { rename-item $_ $_.Name.Replace("test", "test1") } to change the file's name, but ended up getting an error .
– user91
Nov 27 '18 at 13:59
See my answer for this rename effort.
– postanote
Nov 28 '18 at 0:00
add a comment |
Here is a sample of the script for Word Document that I am working on it at the moment
The script changes a word in all of the files, but **** does not **** change part of the file name and Header and Footer
$objWord = New-Object -comobject Word.Application
$objWord.Visible = $false
$list = Get-ChildItem "C:Users*.*" -Include *.doc*
foreach($item in $list){
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
}
$objWord.Quit()
Heres the scrip to change a part of the file name :
PS C:User> get-childitem | foreach { rename-item $_ $_.Name.Replace("file1", "computer") }
How can I put everything together ?
Thanks
powershell scripting
Here is a sample of the script for Word Document that I am working on it at the moment
The script changes a word in all of the files, but **** does not **** change part of the file name and Header and Footer
$objWord = New-Object -comobject Word.Application
$objWord.Visible = $false
$list = Get-ChildItem "C:Users*.*" -Include *.doc*
foreach($item in $list){
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
}
$objWord.Quit()
Heres the scrip to change a part of the file name :
PS C:User> get-childitem | foreach { rename-item $_ $_.Name.Replace("file1", "computer") }
How can I put everything together ?
Thanks
powershell scripting
powershell scripting
asked Nov 21 '18 at 18:34
user91user91
267
267
1
There is nothing in your word code that addresses you header footer needs. Changing the file name or part of the file name is a common practice, with examples in the help files and all over the web and on this site. stackoverflow.com/questions/24887905/…, your rename command is static, but you say you are hitting multiple files. Are you say, all files, contain the word file1, and you are trying to replace the files1 with the word computer? That comes off as all files are name the same, which is not a thing.
– postanote
Nov 22 '18 at 3:32
I was wondering if theres a way to combine all of it. I do understand that the code does not address header and footer. Wondering If someone could help
– user91
Nov 26 '18 at 12:22
@postanote stackoverflow.com/questions/46041100/… this is what I was talking about, but I tried to add this code : get-childitem |foreach { rename-item $_ $_.Name.Replace("test", "test1") } to change the file's name, but ended up getting an error .
– user91
Nov 27 '18 at 13:59
See my answer for this rename effort.
– postanote
Nov 28 '18 at 0:00
add a comment |
1
There is nothing in your word code that addresses you header footer needs. Changing the file name or part of the file name is a common practice, with examples in the help files and all over the web and on this site. stackoverflow.com/questions/24887905/…, your rename command is static, but you say you are hitting multiple files. Are you say, all files, contain the word file1, and you are trying to replace the files1 with the word computer? That comes off as all files are name the same, which is not a thing.
– postanote
Nov 22 '18 at 3:32
I was wondering if theres a way to combine all of it. I do understand that the code does not address header and footer. Wondering If someone could help
– user91
Nov 26 '18 at 12:22
@postanote stackoverflow.com/questions/46041100/… this is what I was talking about, but I tried to add this code : get-childitem |foreach { rename-item $_ $_.Name.Replace("test", "test1") } to change the file's name, but ended up getting an error .
– user91
Nov 27 '18 at 13:59
See my answer for this rename effort.
– postanote
Nov 28 '18 at 0:00
1
1
There is nothing in your word code that addresses you header footer needs. Changing the file name or part of the file name is a common practice, with examples in the help files and all over the web and on this site. stackoverflow.com/questions/24887905/…, your rename command is static, but you say you are hitting multiple files. Are you say, all files, contain the word file1, and you are trying to replace the files1 with the word computer? That comes off as all files are name the same, which is not a thing.
– postanote
Nov 22 '18 at 3:32
There is nothing in your word code that addresses you header footer needs. Changing the file name or part of the file name is a common practice, with examples in the help files and all over the web and on this site. stackoverflow.com/questions/24887905/…, your rename command is static, but you say you are hitting multiple files. Are you say, all files, contain the word file1, and you are trying to replace the files1 with the word computer? That comes off as all files are name the same, which is not a thing.
– postanote
Nov 22 '18 at 3:32
I was wondering if theres a way to combine all of it. I do understand that the code does not address header and footer. Wondering If someone could help
– user91
Nov 26 '18 at 12:22
I was wondering if theres a way to combine all of it. I do understand that the code does not address header and footer. Wondering If someone could help
– user91
Nov 26 '18 at 12:22
@postanote stackoverflow.com/questions/46041100/… this is what I was talking about, but I tried to add this code : get-childitem |foreach { rename-item $_ $_.Name.Replace("test", "test1") } to change the file's name, but ended up getting an error .
– user91
Nov 27 '18 at 13:59
@postanote stackoverflow.com/questions/46041100/… this is what I was talking about, but I tried to add this code : get-childitem |foreach { rename-item $_ $_.Name.Replace("test", "test1") } to change the file's name, but ended up getting an error .
– user91
Nov 27 '18 at 13:59
See my answer for this rename effort.
– postanote
Nov 28 '18 at 0:00
See my answer for this rename effort.
– postanote
Nov 28 '18 at 0:00
add a comment |
1 Answer
1
active
oldest
votes
That last code segment is outside of what you are doing in word. So, when you say combine, it's just as you are already doing:
You are not saying / showing what error you are getting form this last code segment.
When trying to rename files, you have to use the full filename, and that includes the path to that file, just as you did in the word segment.
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 OriginalFileName.txt
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
What if: Performing the operation "Rename File" on target "Item: E:TempOriginalFileName.txt Destination: E:TempNewFileName.txt".
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) }
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 NewFileName.txt
foreach($item in $list)
{
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
Rename-Item -Path $item.FullName -NewName ($item.FullName.Replace($item.BaseName,$FindText)) -WhatIf
}
$objWord.Quit()
Just remove the -WhatIf to have it run for real of course.
Thank you. I will try to run it later
– user91
Nov 28 '18 at 12:34
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418517%2fpowershell-how-to-put-the-following-script-together-adjust-header-and-footer%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
That last code segment is outside of what you are doing in word. So, when you say combine, it's just as you are already doing:
You are not saying / showing what error you are getting form this last code segment.
When trying to rename files, you have to use the full filename, and that includes the path to that file, just as you did in the word segment.
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 OriginalFileName.txt
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
What if: Performing the operation "Rename File" on target "Item: E:TempOriginalFileName.txt Destination: E:TempNewFileName.txt".
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) }
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 NewFileName.txt
foreach($item in $list)
{
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
Rename-Item -Path $item.FullName -NewName ($item.FullName.Replace($item.BaseName,$FindText)) -WhatIf
}
$objWord.Quit()
Just remove the -WhatIf to have it run for real of course.
Thank you. I will try to run it later
– user91
Nov 28 '18 at 12:34
add a comment |
That last code segment is outside of what you are doing in word. So, when you say combine, it's just as you are already doing:
You are not saying / showing what error you are getting form this last code segment.
When trying to rename files, you have to use the full filename, and that includes the path to that file, just as you did in the word segment.
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 OriginalFileName.txt
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
What if: Performing the operation "Rename File" on target "Item: E:TempOriginalFileName.txt Destination: E:TempNewFileName.txt".
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) }
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 NewFileName.txt
foreach($item in $list)
{
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
Rename-Item -Path $item.FullName -NewName ($item.FullName.Replace($item.BaseName,$FindText)) -WhatIf
}
$objWord.Quit()
Just remove the -WhatIf to have it run for real of course.
Thank you. I will try to run it later
– user91
Nov 28 '18 at 12:34
add a comment |
That last code segment is outside of what you are doing in word. So, when you say combine, it's just as you are already doing:
You are not saying / showing what error you are getting form this last code segment.
When trying to rename files, you have to use the full filename, and that includes the path to that file, just as you did in the word segment.
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 OriginalFileName.txt
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
What if: Performing the operation "Rename File" on target "Item: E:TempOriginalFileName.txt Destination: E:TempNewFileName.txt".
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) }
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 NewFileName.txt
foreach($item in $list)
{
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
Rename-Item -Path $item.FullName -NewName ($item.FullName.Replace($item.BaseName,$FindText)) -WhatIf
}
$objWord.Quit()
Just remove the -WhatIf to have it run for real of course.
That last code segment is outside of what you are doing in word. So, when you say combine, it's just as you are already doing:
You are not saying / showing what error you are getting form this last code segment.
When trying to rename files, you have to use the full filename, and that includes the path to that file, just as you did in the word segment.
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 OriginalFileName.txt
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) -WhatIf }
What if: Performing the operation "Rename File" on target "Item: E:TempOriginalFileName.txt Destination: E:TempNewFileName.txt".
Get-ChildItem -Path 'E:Temp' -Filter '*.txt' |
ForEach { Rename-Item -Path $_.FullName -NewName ($_.FullName.Replace('Original','New')) }
Get-ChildItem -Path E:Temp -Filter '*.txt'
Directory: E:Temp
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/27/2018 3:51 PM 0 NewFileName.txt
foreach($item in $list)
{
$objDoc = $objWord.Documents.Open($item.FullName,$true)
$objSelection = $objWord.Selection
$wdFindContinue = 1
$FindText = "COMPUTER"
$MatchCase = $False
$MatchWholeWord = $true
$MatchWildcards = $False
$MatchSoundsLike = $False
$MatchAllWordForms = $False
$Forward = $True
$Wrap = $wdFindContinue
$Format = $False
$wdReplaceNone = 0
$ReplaceWith = "DESKTOP"
$wdFindContinue = 1
$ReplaceAll = 2
$a = $objSelection.Find.Execute($FindText,$MatchCase,$MatchWholeWord, `
$MatchWildcards,$MatchSoundsLike,$MatchAllWordForms,$Forward,`
$Wrap,$Format,$ReplaceWith,$ReplaceAll)
$objDoc.Save()
$objDoc.Close()
Rename-Item -Path $item.FullName -NewName ($item.FullName.Replace($item.BaseName,$FindText)) -WhatIf
}
$objWord.Quit()
Just remove the -WhatIf to have it run for real of course.
edited Nov 28 '18 at 0:10
answered Nov 28 '18 at 0:00
postanotepostanote
3,1832410
3,1832410
Thank you. I will try to run it later
– user91
Nov 28 '18 at 12:34
add a comment |
Thank you. I will try to run it later
– user91
Nov 28 '18 at 12:34
Thank you. I will try to run it later
– user91
Nov 28 '18 at 12:34
Thank you. I will try to run it later
– user91
Nov 28 '18 at 12:34
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53418517%2fpowershell-how-to-put-the-following-script-together-adjust-header-and-footer%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
There is nothing in your word code that addresses you header footer needs. Changing the file name or part of the file name is a common practice, with examples in the help files and all over the web and on this site. stackoverflow.com/questions/24887905/…, your rename command is static, but you say you are hitting multiple files. Are you say, all files, contain the word file1, and you are trying to replace the files1 with the word computer? That comes off as all files are name the same, which is not a thing.
– postanote
Nov 22 '18 at 3:32
I was wondering if theres a way to combine all of it. I do understand that the code does not address header and footer. Wondering If someone could help
– user91
Nov 26 '18 at 12:22
@postanote stackoverflow.com/questions/46041100/… this is what I was talking about, but I tried to add this code : get-childitem |foreach { rename-item $_ $_.Name.Replace("test", "test1") } to change the file's name, but ended up getting an error .
– user91
Nov 27 '18 at 13:59
See my answer for this rename effort.
– postanote
Nov 28 '18 at 0:00