Skip to content

Commit 282382d

Browse files
author
Daniel Sundberg
committed
Add README documentation
1 parent 6ce96d0 commit 282382d

File tree

2 files changed

+40
-19
lines changed

2 files changed

+40
-19
lines changed

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# CopyImages
2+
3+
Powershell script to copy files from memory card to folder on disk.
4+
5+
## Usage:
6+
<code>
7+
.\copy-images.ps1 -indir "e:" -outdir "c:\images" -today
8+
</code>
9+
10+
<code>
11+
.\copy-images.ps1 -indir "e:" -outdir "c:\images" -from "2015-01-01" -to "2015-02-28"
12+
</code>
13+
14+
## Optional switches
15+
<code>
16+
-ymdPath
17+
</code>
18+
19+
When set to **true**, create paths in **outdir** on the format **\yyyy\mm\dd**
20+
(year (4 digits)/month (2 digits)/day of month (2 digits)). This is the default
21+
behavior. Set to **false** if you want paths of format **yyyy-mm-dd**.
22+
23+
## Possible improvements
24+
* Handle more raw file extensions
25+
* Start cmdlet when memory card is inserted
26+
* Handle more camera models if needed (tested with Nikon D40 and Sony RX100)
27+
* Improve dry-run output
28+
* Log to file as default
29+
* Auto detect memory card path
30+
* Remember input and output dir
31+
* Config file for input/output dir

copy-images.ps1

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
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-
101
param (
112
[switch]$dryRun = $false,
123
[string]$indir = "e:\",
@@ -23,12 +14,12 @@ trap
2314
write-output $_
2415
exit 1
2516
}
26-
17+
2718
$rawFiles = "*.NEF"
2819
$jpgFiles = "*.JPG"
2920

3021
$rawOutdir = join-path -Path $outdir -ChildPath "Raw"
31-
22+
3223
# Parse dates
3324
$fromDate = [DateTime]::MinValue
3425
if ($from.length -gt 0)
@@ -47,7 +38,7 @@ if ($today)
4738
$fromDate = (get-date).date
4839
$toDate = (get-date).date.AddDays(1)
4940
}
50-
41+
5142
echo "Starting..."
5243
echo "In dir: $indir"
5344
echo "Out dir: $outdir"
@@ -74,14 +65,14 @@ foreach ($item in $files)
7465
echo "$i of $nofFiles"
7566
$i += 1
7667
$date = $item | get-date
77-
68+
7869
# Check that file date is in our date interval
7970
if (($date -gt $fromDate) -and ($date -lt $toDate))
8071
{
8172
$shortDate = $date.ToString("yyyy-MM-dd")
8273
$fullName = $item.FullName
8374
$name = $item.Name
84-
75+
8576
if ($item.Extension.ToUpper() -eq ".NEF")
8677
{
8778
$destPath = join-path -Path $outdir -ChildPath "Raw"
@@ -90,14 +81,14 @@ foreach ($item in $files)
9081
{
9182
$destPath = $outdir
9283
}
93-
84+
9485
# Create destination path of specified format <out_path>\<date>
9586
# or <out_path>\year\mm\<date>
9687
if ($ymdPath)
9788
{
9889
$destPath = join-path -Path (join-path -Path (join-path -Path $destPath -ChildPath $date.year) -ChildPath $date.month) -ChildPath $shortDate
9990
}
100-
else
91+
else
10192
{
10293
$destPath = join-path -Path $destPath -ChildPath $shortDate
10394
}
@@ -110,9 +101,9 @@ foreach ($item in $files)
110101
mkdir $destPath
111102
}
112103
}
113-
104+
114105
$destFile = join-path -Path $destPath -ChildPath $name
115-
106+
116107
if (!(Test-Path -Path $destFile))
117108
{
118109
echo "Copying $fullName to $destFile..."
@@ -123,4 +114,3 @@ foreach ($item in $files)
123114
}
124115
}
125116
}
126-

0 commit comments

Comments
 (0)