Hi all :)
I have a question;
Consider this:
I have a folder called TEST\;
Underneath there are other folders, like A, B, C.
In each folder, there is a file called FILE.TXT
\TEST\A\FILE.TXT
\TEST\B\FILE.TXT
\TEST\C\FILE.TXT
Im trying to write a PS script to go through all sub directories recursively and copy the FILE.TXT to FILE1.TXT, thus creating the following:
\TEST\A\FILE.TXT
\TEST\A\FILE1.TXT
\TEST\B\FILE.TXT
\TEST\B\FILE1.TXT
\TEST\C\FILE.TXT
\TEST\C\FILE1.TXT
Now, what i've come up with in the last 1.5 hours:
get-childitem -recurse | Where {$_.name -eq "test.txt"} |
ForEach-Object {}
This is basically it. I can use the Rename-Item cmdlet to rename all files to something else, but once i try to use the Copy-Item, it will bug me for a path location.
I also tried to use
$files = ls . test.txt -recurse
Where $files will show as output all the files in the directories, but i can't seem to get the copy-item to function with it.
Could some1 show me how the script should look like? I am very n00b to PowerShell; I know what i want, but i simply don't know the syntaxes etc.
Kind regards!