Feeds:
Posts
Comments

Archive for December, 2009

I have a text file and in that file list of files and folder are available to copy from a local computer to a remote computer. This is very easy to do using powershell. Example is as follows

$remotePCName = “remotePC”
$remoteRoot = “\\$remotePCName\c$”
$DestFolder=”$remoteRoot\FileCopy\dest”
$SrcFolder=”C:\FileCopy\src”
$InputFile =”C:\FilesToExport.txt”

foreach ($FileLine in Get-Content $InputFile)
{
$src = $FileLine
$dest = $src.Replace($SrcFolder, $DestFolder)
if(!(test-path -path $dest))
{
if((get-item $src).PSIsContainer)
{
new-Item $dest -type Directory -force | out-Null
Copy-Item “$src\*” $dest -recurse
“Folder $dest Missing. Creating it!”
}
else
{
new-Item $dest -type File -force | out-Null
Copy-Item $src $dest -force
“File $dest Missing. Creating it!”
}
}
else
{
if((get-item $src).PSIsContainer)
{
Copy-Item “$src\*” $dest -recurse
“Copy file done for $src”
}
else
{
Copy-Item $src $dest -force
“Copy file done for $src”
}
}
}

a file syncronizer can be created by some code modification easily.

Read Full Post »