{"id":4324,"date":"2013-01-14T11:59:00","date_gmt":"2013-01-14T11:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/01\/14\/powertip-find-files-using-the-wrong-year\/"},"modified":"2013-01-14T11:59:00","modified_gmt":"2013-01-14T11:59:00","slug":"powertip-find-files-using-the-wrong-year","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-find-files-using-the-wrong-year\/","title":{"rendered":"PowerTip: Find Files Using the Wrong Year"},"content":{"rendered":"<p><strong>Summary:<\/strong>&nbsp;Use Windows PowerShell to find files using the wrong year in the file name.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;I have files that use the month, day, and year in their file names. I recently discovered that some years are not using the new year in their file names. How can I easily find these files?<\/p>\n<p style=\"padding-left: 60px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Use the&nbsp;<strong>Get-ChildItem<\/strong>&nbsp;cmdlet to find the files in the folder. Use a wild card pattern in the&nbsp;<strong>Where-Object<\/strong>&nbsp;command to filter out these files. The following illustrates this technique by using Windows PowerShell&nbsp;3.0 syntax, where&nbsp;<strong>gci<\/strong>&nbsp;is the alias for&nbsp;<strong>Get-ChildItem<\/strong>&nbsp;and&nbsp;<strong>?<\/strong>&nbsp;is the alias for&nbsp;<strong>Where-Object<\/strong>:<\/p>\n<p style=\"padding-left: 120px\">15:42 C:\\&gt; gci -Recurse C:\\data\\ScriptingGuys\\2013 | ? name -like &#8216;???-?-*-12-*<\/p>\n<p style=\"padding-left: 120px\">&nbsp;&nbsp;&nbsp; Directory: C:\\data\\ScriptingGuys\\2013\\HSG_1_7_13<\/p>\n<p style=\"padding-left: 120px\">Mode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LastWriteTime&nbsp;&nbsp;&nbsp;&nbsp; Length Name<\/p>\n<p style=\"padding-left: 120px\">&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212; &#8212;-<\/p>\n<p style=\"padding-left: 120px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/10\/2013&nbsp;&nbsp; 1:21 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20383 HSG-1-11-12-01.png<\/p>\n<p style=\"padding-left: 120px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/10\/2013&nbsp;&nbsp; 1:24 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19952 HSG-1-11-12-02.png<\/p>\n<p style=\"padding-left: 120px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/10\/2013&nbsp;&nbsp; 1:26 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 24238 HSG-1-11-12-03.png<\/p>\n<p style=\"padding-left: 120px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/10\/2013&nbsp;&nbsp; 1:37 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 42781 HSG-1-11-12-04.png<\/p>\n<p style=\"padding-left: 120px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/10\/2013&nbsp;&nbsp; 1:37 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12472 HSG-1-11-12-05.png<\/p>\n<p style=\"padding-left: 120px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/11\/2013&nbsp; 12:35 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 28651 HSG-1-12-12-01.png<\/p>\n<p style=\"padding-left: 120px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/11\/2013&nbsp; 12:43 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 38762 HSG-1-12-12-02.png<\/p>\n<p style=\"padding-left: 120px\">&#8212;&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/11\/2013&nbsp;&nbsp; 1:13 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25456 HSG-1-12-12-03.png<\/p>\n<p style=\"padding-left: 120px\">-a&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1\/11\/2013&nbsp;&nbsp; 1:13 PM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16030 HSG-1-12-12-04.png<\/p>\n<p style=\"padding-left: 60px\">For Windows PowerShell&nbsp;1.0 or Windows PowerShell&nbsp;2.0 syntax, the command is:<\/p>\n<p style=\"padding-left: 120px\">gci -Recurse C:\\data\\ScriptingGuys\\2013 | ? {$_.name -like &#8216;???-?-*-12-*&#8217;}<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\"\" border=\"0\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary:&nbsp;Use Windows PowerShell to find files using the wrong year in the file name. &nbsp;I have files that use the month, day, and year in their file names. I recently discovered that some years are not using the new year in their file names. How can I easily find these files? &nbsp;Use the&nbsp;Get-ChildItem&nbsp;cmdlet to find [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[356,3,45],"class_list":["post-4324","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary:&nbsp;Use Windows PowerShell to find files using the wrong year in the file name. &nbsp;I have files that use the month, day, and year in their file names. I recently discovered that some years are not using the new year in their file names. How can I easily find these files? &nbsp;Use the&nbsp;Get-ChildItem&nbsp;cmdlet to find [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=4324"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/4324\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=4324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=4324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=4324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}