how to use powershell to copy file and retain original timestamp -
i copy files or folder of files 1 file server another. however, want keep original timestamp , file attributes newly copied files have same timestamp of original files. in advance on answer.
here's powershell function that'll you're asking... absolutely no sanity checking, caveat emptor...
function copy-filewithtimestamp { [cmdletbinding()] param( [parameter(mandatory=$true,position=0)][string]$path, [parameter(mandatory=$true,position=1)][string]$destination ) $origlastwritetime = ( get-childitem $path ).lastwritetime copy-item -path $path -destination $destination (get-childitem $destination).lastwritetime = $origlastwritetime }
once you've run loaded that, can like:
copy-filewithtimestamp foo bar
(you can name shorter, tab completion, not big of deal...)
Comments
Post a Comment