-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckModDate
More file actions
59 lines (34 loc) · 1007 Bytes
/
CheckModDate
File metadata and controls
59 lines (34 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Get all files in folder and (subfolder -recurse)
$files = Get-ChildItem \\server\Staff\tfolder1\ -recurse
$2ndfiles = Get-ChildItem \\server\folder2\ -recurse
foreach ($file in $files)
{
#Gets only the date from the last modified time
$a = $file | Select-Object LastWriteTime |ForEach-Object($_.LastWriteTime){Write-Output $_.LastWriteTime}
$b = [datetime]$a
$d = [datetime]"09/15/13"
$e = [string]$d
$testFileName = $file.DirectoryName+"\"+$file.Name
#test to see if it is a file or folder (folders don't work right) returns true if it is a file
test-path $testFileName
IF (test-path $testFileName)
{
IF ($b -gt $d)
{
#$fileName = $file.DirectoryName+"\"+$file.Name
$filename
foreach ($2ndfile in $2ndfiles)
{
$2ndfileName = $2ndfile.DirectoryName+"\"+$2ndfile.Name
if ($2ndfile.Name -eq $file.Name)
{
Remove-Item $filename
Copy-Item $2ndfileName $file.DirectoryName
}
}
"do this"
}
ELSE
{"You are fine"}
}
}