{"id":93,"date":"2020-10-04T00:59:51","date_gmt":"2020-10-04T00:59:51","guid":{"rendered":"https:\/\/3735943886.com\/?p=93"},"modified":"2020-10-13T23:32:57","modified_gmt":"2020-10-13T23:32:57","slug":"modify-file-time-stamps-via-powershell","status":"publish","type":"post","link":"https:\/\/3735943886.com\/?p=93","title":{"rendered":"Modify File Time Stamps using PowerShell"},"content":{"rendered":"<pre class=\"txc-textbox\" style=\"background-color: #dbe8fb; border: #79a5e4 3px double; padding: 10px;\">Usages:\n(Get-Item <u>[filename]<\/u>).CreationTime = <u>[date\/time]<\/u>\n(Get-Item <u>[filename]<\/u>).LastAccessTime = <u>[date\/time]<\/u>\n(Get-Item <u>[filename]<\/u>).LastWriteTime = <u>[date\/time]<\/u>\n\nPS C:\\&gt; (<span style=\"color: #ffbb00;\">Get-Item<\/span> .\\test.txt).LastAccessTime = <span style=\"color: #ffbb00;\">Get-Date<\/span>\n\u2192 This command converts 'last access time' of 'test.txt' to current date and time\n\nPS C:\\&gt; (<span style=\"color: #ffbb00;\">Get-Item<\/span> .\\christmas.tree).LastWriteTime = '<span style=\"color: #22741c;\">2016-12-25 AM0:00<\/span>'\n\u2192 This command converts 'last write&nbsp;time' of&nbsp;'christmas.tree' to specific date and time<\/pre>\n<pre class=\"txc-textbox\" style=\"background-color: #dbe8fb; border: #79a5e4 3px double; padding: 10px;\">Batch Processing with ForEach:\nGet-ChildItem | ForEach-Object { $_.<u>LastWriteTime<\/u> = <u>Get-Date<\/u> }\n\nPS C:\\&gt; <span style=\"color: #ffbb00;\">Get-ChildItem<\/span> | <span style=\"color: #ffbb00;\">ForEach-Object<\/span> { <span style=\"color: #22741c;\">$_<\/span>.LastWriteTime = <span style=\"color: #ffbb00;\">Get-Date<\/span> }\n\u2192 This command converts 'last write time' to current date and time of all files in working directory\n\nPS C:\\&gt; <span style=\"color: #22741c;\">$i<\/span> = 0; <span style=\"color: #ffbb00;\">Get-ChildItem<\/span> | <span style=\"color: #ffbb00;\">ForEach-Object<\/span> { <span style=\"color: #22741c;\">$_<\/span>.LastWriteTime = (<span style=\"color: #ffbb00;\">Get-Date<\/span>).AddDays(-1).AddMinutes(<span style=\"color: #22741c;\">$i<\/span>++) }\n\u2192 This command converts 'last write&nbsp;time' to yesterday with&nbsp;increasing minutes<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Usages: (Get-Item [filename]).CreationTime = [date\/time] (Get-Item [filename]).LastAccessTime = [date\/time] (Get-Item [filename]).LastWriteTime = [date\/time] PS C:\\&gt; (Get-Item .\\test.txt).LastAccessTime = Get-Date \u2192 This command converts &#8216;last access time&#8217; of &#8216;test.txt&#8217; to current date and time PS C:\\&gt; (Get-Item .\\christmas.tree).LastWriteTime = &#8216;2016-12-25 AM0:00&#8217; \u2192 This command converts &#8216;last write&nbsp;time&#8217; of&nbsp;&#8216;christmas.tree&#8217; to specific date and time Batch Processing with &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/3735943886.com\/?p=93\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Modify File Time Stamps using PowerShell&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[87,88,89,90,26,91],"class_list":["post-93","post","type-post","status-publish","format-standard","hentry","category-os","tag-get-date","tag-get-item","tag-lastaccesstime","tag-lastwritetime","tag-powershell","tag-timestamp"],"_links":{"self":[{"href":"https:\/\/3735943886.com\/index.php?rest_route=\/wp\/v2\/posts\/93","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/3735943886.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/3735943886.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/3735943886.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/3735943886.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=93"}],"version-history":[{"count":8,"href":"https:\/\/3735943886.com\/index.php?rest_route=\/wp\/v2\/posts\/93\/revisions"}],"predecessor-version":[{"id":121,"href":"https:\/\/3735943886.com\/index.php?rest_route=\/wp\/v2\/posts\/93\/revisions\/121"}],"wp:attachment":[{"href":"https:\/\/3735943886.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=93"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/3735943886.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=93"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/3735943886.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=93"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}