1
- # Possible improvements
2
- # -Handle more raw file formats
3
- # -Start cmdlet when memory card is inserted
4
- # -Handle more camera models
5
- # -Improve dry-run output
6
- # -Log to file as default
7
- # -Log levels for debugging
8
-
9
-
10
1
param (
11
2
[switch ]$dryRun = $false ,
12
3
[string ]$indir = " e:\" ,
23
14
write-output $_
24
15
exit 1
25
16
}
26
-
17
+
27
18
$rawFiles = " *.NEF"
28
19
$jpgFiles = " *.JPG"
29
20
30
21
$rawOutdir = join-path - Path $outdir - ChildPath " Raw"
31
-
22
+
32
23
# Parse dates
33
24
$fromDate = [DateTime ]::MinValue
34
25
if ($from.length -gt 0 )
@@ -47,7 +38,7 @@ if ($today)
47
38
$fromDate = (get-date ).date
48
39
$toDate = (get-date ).date.AddDays(1 )
49
40
}
50
-
41
+
51
42
echo " Starting..."
52
43
echo " In dir: $indir "
53
44
echo " Out dir: $outdir "
@@ -74,14 +65,14 @@ foreach ($item in $files)
74
65
echo " $i of $nofFiles "
75
66
$i += 1
76
67
$date = $item | get-date
77
-
68
+
78
69
# Check that file date is in our date interval
79
70
if (($date -gt $fromDate ) -and ($date -lt $toDate ))
80
71
{
81
72
$shortDate = $date.ToString (" yyyy-MM-dd" )
82
73
$fullName = $item.FullName
83
74
$name = $item.Name
84
-
75
+
85
76
if ($item.Extension.ToUpper () -eq " .NEF" )
86
77
{
87
78
$destPath = join-path - Path $outdir - ChildPath " Raw"
@@ -90,14 +81,14 @@ foreach ($item in $files)
90
81
{
91
82
$destPath = $outdir
92
83
}
93
-
84
+
94
85
# Create destination path of specified format <out_path>\<date>
95
86
# or <out_path>\year\mm\<date>
96
87
if ($ymdPath )
97
88
{
98
89
$destPath = join-path - Path (join-path - Path (join-path - Path $destPath - ChildPath $date.year ) - ChildPath $date.month ) - ChildPath $shortDate
99
90
}
100
- else
91
+ else
101
92
{
102
93
$destPath = join-path - Path $destPath - ChildPath $shortDate
103
94
}
@@ -110,9 +101,9 @@ foreach ($item in $files)
110
101
mkdir $destPath
111
102
}
112
103
}
113
-
104
+
114
105
$destFile = join-path - Path $destPath - ChildPath $name
115
-
106
+
116
107
if (! (Test-Path - Path $destFile ))
117
108
{
118
109
echo " Copying $fullName to $destFile ..."
@@ -123,4 +114,3 @@ foreach ($item in $files)
123
114
}
124
115
}
125
116
}
126
-
0 commit comments