Powertip Of The Day-changing file/Folder creation date

Source: Internet
Author: User

Original article address:Http://app.en25.com/e/es.aspx? S = 1403 & E = 4273 & elq = 1cbc05ed0b11413db47a3b65bc2ee7a4

Original article:

 

Changing file/Folder creation date

You shoshould use this approach if you need to change the creation time of a folder or file after you have created it:

Get-childitem c: \ testfolder | foreach-object {$ _. creationtime = '2017/24/60'

It will change creation time of c: \ testfolder to the date and time specified. note that the date-time format used here needs to match your local date-time format. A more general approach wocould be to use get-date with its parameters to construct a culture-neutral date and assign that to the file/folder creationdate property.

 

Translation:

Change the file or folder Creation Time

Use the following method to change the creation time of a created file or folder.

Get-childitem c: \ testfolder | foreach-object {$ _. creationtime = '2017/24/60'}

This sectionCodeWill changeC: \ testfolderIs a specified time. Note that the time format must be consistent with the time format of the local machine. The common practice is to useGet-DateAdd appropriate parameters to build a date and assign it to the creation date attribute of the file or folder.

 

Notes:

The original code has a problem,ForeachLess than one}End tag.

The logic of the original code is to change the creation date of all elements in a specified folder, so the title does not seem appropriate. However, the meaning is clearly expressed.

Below Cmdlet Usage: Get-childitem ( Strange why not Get-childrenitems) , Foreach-object ( No Foreach, Clearer )

Test found1972Such a date is displayed as null in the system, and it is normal to replace it with a relatively recent date.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.