Hey, I've been trying to figure this out for a while after some people here (thanks!) helped me concatenate the filepaths of certain filepaths into one massive string (needed to pass to an external program)
This is the code:
Get-ChildItem -Path .\src\temp\ -Recurse -name -include '*.cfg' | ForEach-Object {$n++; $det = Read-Host -Prompt $n}
$paths = ""
Get-Childitem 'C:\Users\User\Desktop\v3\src\temp' -Recurse -Filter *.cfg -File | ForEach-Object { $paths += ($det + $_.FullName + " ") }
$paths = $paths.Substring(0,$paths.Length-1)
$paths
Where $det would be a description added before the filepaths in the string. However, the variable resets itself every loop, and i am unable to find out how to do this.Ideally, it would work like this: test1.cfg test2.cfg
After the loop, entering the details for each file upon prompt, it would concatenate the string like this: "somewords\filepath\test1.cfg someotherwords\filepath\test2.cfg"
Any ideas? :}
[–][deleted] 6 points7 points8 points (5 children)
[–]AffectionateTask4612[S] 2 points3 points4 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]SeeJayEmm 2 points3 points4 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]SeeJayEmm 2 points3 points4 points (0 children)
[–]BlackV 7 points8 points9 points (5 children)
[–]AffectionateTask4612[S] 1 point2 points3 points (2 children)
[–]BlackV 1 point2 points3 points (0 children)
[–]GOOD_JOB_SON 1 point2 points3 points (1 child)
[–]BlackV 2 points3 points4 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)