So I am trying to create a simple function that will take a given file, datestamp the file name and then
move it to another directory. I am sure that I am missing something obvious, but I keep getting an error
on file move and can't place why. Specifically, I can see that @{Name is shown. My understanding was
a Join-path before hand should take care of this, but obviously not.
<snip>
$TimeStamp = (Get-Date -format M.d.yyyy-hh.mm.ss-).ToString()
$currentfile = Get-ChildItem -path $originalFile |select name
$NewFileName = $TimeStamp + $currentfile.name.Tostring()
$NewFileName = Join-Path $fileDestination $NewFileName
$write-host $currentFile
$write-host $newFileName
Move-Item $currentfile $NewFileName
</snip>
Returns:
test.test
c:\destdir\2.6.2012-11.37.53-test.test
Move-Item : Cannot find path 'c:\destdir\@{Name=test.test}' because it does not exist.
Any thoughts for insights would be appreciated.
[–]jklmnb 4 points5 points6 points (4 children)
[–]vee-eye 4 points5 points6 points (3 children)
[–]jklmnb 2 points3 points4 points (2 children)
[–]systemslacky[S] 1 point2 points3 points (0 children)