-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcDariy.ps1
57 lines (48 loc) · 1.79 KB
/
cDariy.ps1
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
55
56
57
#Script End
#日期
$date = Get-Date -format 'yyyy·MM·dd'
$year = Get-Date -format 'yyyy'
$month = Get-Date -format 'MM'
#文件名
$fileName = $date +'.md'
#当前地址
$path = Split-Path -Parent $MyInvocation.MyCommand.Definition
#文件夹
$filer = $path +'\dairy\'+$year+'\'
#文件
$file = $path +'\dairy\'+$year+'\'+$month+'\' + $fileName
#$files = $path +'\dairy\' + $fileName
if(Test-Path $filer){
}else{
mkdir $filer
}
$filer = $filer+'\'+$month+'\'
if(Test-Path $filer){
}else{
mkdir $filer
}
if(Test-Path $file){
"文件已存在,不重新创建"
}else{
#引入模板地址
$template = $path +'\dairy\template.txt'
if(Test-Path $template){
}else{
$temp1 = '
## 目录
<!-- TOC -->
<!-- /TOC -->
## 内容
###
## 总结
'
$temp1 > $template
}
#读取模板
$content = Get-Content -Path $template -Raw -encoding utf8
$content = "# "+ $date + $content
## 创建文件
$content > $file
}
$file
#Script Really End