(/いくつかの)テキストファイルの作成日を変更し、別のコンピューターにコピーしたときにそれを保持する方法


0

複数のテキストファイルがあり、これらのファイルの作成日を変更したい。私はいくつかの問題を抱えていますので、私のケースについてアドバイスをいただければ幸いです。

最初に、1つのファイルの作成日を変更するこのソリューションを見つけました。powershell(windows 10)を実行することを伴います

 (Get-Item test2.txt).creationtime=$(Get-Date "1/2/2016 12
:34 am")

できます。そこで、2つの問題があります。まず、これを1000個のファイルに行う方法は?自動化する必要がありますか、時間がかかりすぎます。

ただし、2番目の問題ははるかに重要です。このファイルの作成日を変更した後、これを別の場所にコピーすると、コピーされたファイルの作成日は今日に戻りました。さらに悪いことに、これらの10000個のファイル(作成日を変更した)をWindows 7システムにコピーし、これらの古い作成時間のファイルを用意する必要がありました。しかし、彼らが今日に戻り、そこでシェルを持たない場合、どうすれば問題を解決できますか?

回答:


0

あなたが求めている答えはすべて、PowerShellヘルプファイルにあります。

# Get a list of all functions
Get-Command -CommandType Function | 
Out-GridView -PassThru -Title 'Available functions'


# Get a list of all commandlets
Get-Command -CommandType Cmdlet | 
Out-GridView -PassThru -Title 'Available cmdlets'


# Get a list of all functions for the specified name
Get-Command -Name '*ADGroup*' -CommandType Function | 
Out-GridView -PassThru -Title 'Available named functions'


# Get a list of all commandlets for the specified name
Get-Command -Name '*ADGroup**'  -CommandType Cmdlet | 
Out-GridView -PassThru -Title 'Available named cmdlet'


# get function / cmdlet details
(Get-Command -Name Get-ChildItem).Parameters
Get-help -Name Get-ChildItem -Examples
Get-help -Name Get-ChildItem -Full
Get-help -Name Get-ChildItem -Online


(Get-Command -Name ForEach).Parameters
Get-help -Name ForEach -Examples
Get-help -Name ForEach -Full
Get-help -Name ForEach -Online


(Get-Command -Name Copy-Item).Parameters
Get-help -Name Copy-Item -Examples
Get-help -Name Copy-Item -Full
Get-help -Name Copy-Item -Online


# Get parameter that accept pipeline input
Get-Help Get-ChildItem -Parameter * | 
Where-Object {$_.pipelineInput -match 'true'} | 
Select * 


Get-Help about_*
Get-Help about_Functions

または、組み込みのrobocopyを使用して、ソースを宛先にコピーします。

robocopy <Source> <Destination> [<File>[ ...]] [<Options>]

/ COPY:[copyflags]および/ DCOPYスイッチのオプションを見てください。

# As per the ROBOCOPY /? usage info:
/COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
                      (copyflags : D=Data, A=Attributes, T=Timestamps).
                      (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).

/DCOPY:T :: COPY Directory Timestamps.


# For example:
ROBOCOPY c:\src d:\dest /MIR /COPY:DT /DCOPY:T


# Will copy all files and folders and preserve the date and time stamps.
ROBOCOPY c:\src d:\dest /MIR /COPY:DAT /DCOPY:T


Will copy all files and folders and preserve the date & time stamps and file attributes.

There is also another (and I believe deprecated?) switch /TIMFIX which does much the same as /COPY:DT but it doesn't fix the time stamps on folders.
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.