Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Unable to concatenate simple filenames with other pre-defined variables to copy files

$
0
0

This is frustrating me immensely!

What I am trying to do is very simple: Obtain a list of files in a folder; append that filename to a new path and submit to a bits-transfer job.  I cannot get the paths to concatenate properly , even if I just use write-host (not bits-transfer) to output the filepaths:

Something like this:

 

$SourcePath = "C:\Folder1"

$DestPath= "C:\Folder2"

$FileList = get-childitem $SourcePath

foreach ($file in $filelist) {write-host $SourcePath\$file.name $DestPath\$file.name}

 

NB C:\Folder1 contains test1.txt and test2.txt.

I get:

C:\Folder1\test1.txt.name C:\Folder2\test1.txt.name

C:\Folder1\test2.txt.name C:\Folder2\test2.txt.name

 

Any help would be appreciated. And yes, I am new to this powershell stuff.

Thanks

Adrian

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles