Last active
February 22, 2019 06:04
-
-
Save auberginehill/e649d84b695dc0e19c365bdbd9bf511a to your computer and use it in GitHub Desktop.
Downloads the most recent Nikon A-GPS update file (NMT_14A.ee) from Nikon to $env:temp (a Windows PowerShell script).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
Download-NikonAGPSUpdateFile.ps1 | |
#> | |
# Set the common parameters | |
# Note: Will overwrite the existing NMT_14A.ee file | |
$ErrorActionPreference = "Stop" | |
$start_time = Get-Date | |
$path = $env:temp | |
$empty_line = "" | |
$filename = "NMT_14A.ee" | |
$save_location = "$path\$filename" | |
$base = "http://download.nikonimglib.com/archive1/" | |
$source = "https://downloadcenter.nikonimglib.com/en/download/fw/112.html" | |
<# | |
Description | |
• Downloads the most recent Nikon A-GPS update file (NMT_14A.ee) from Nikon to $env:temp. The file | |
helps Nikon 1 AW1 and Nikon Coolpix P900/S9900/S9700/S9500/S810c/S800c/AW130/AW120/AW110s/AW110/W300 | |
cameras determine the GPS position faster. | |
Updating the A-GPS File (Nikon Coolpix P900/S9900/S9700/S9500/AW130/AW120/AW110s/AW110/W300) | |
1. Download the latest GPS file from the Nikon website. | |
2. Using a card reader or a similar device, copy the file to the "NCFL" folder on the SD memory card. | |
• The "NCFL" folder can be found in the root directory of the memory card. | |
• If the card does not contain an "NCFL" folder, please create a new folder in the root directory | |
and name it "NCFL". | |
3. After copying the file, insert the card into the camera and turn the camera on. | |
4. Press the MENU button and use the multi selector to select the GPS or location data menu tab. | |
5. Select GPS options or Location data options. | |
6. Select Update A-GPS file to update the file. | |
Expiry Dates | |
• The A-GPS file is valid for 14 days or a multiple of 14 days. | |
• The expiry date for the updated file can be checked in the "Update GPS File" dialog. | |
• If the file has expired, the latest A-GPS file can be downloaded from the Nikon website | |
and the A-GPS data updated as described above. | |
• A-GPS is not available once the A-GPS file has expired. | |
• More time may be required to acquire the current position, if the A-GPS file has expired. | |
• It's recommended that the A-GPS file is updated before using the location data function. | |
Home: https://gist.github.com/auberginehill/e649d84b695dc0e19c365bdbd9bf511a | |
Short URL: https://tinyurl.com/yau2wzkh | |
About A-GPS files: https://www.nikonimgsupport.com/eu/BV_article?articleNo=000006295&configured=1&lang=en_GB | |
Latest firmware updates for Nikon products: https://www.nikonimgsupport.com/eu/BV_article?articleNo=000032994&lang=en_GB | |
Nikon D5300 A-GPS update file (NML_28A.ee): https://downloadcenter.nikonimglib.com/en/download/fw/111.html | |
Nikon 1 AW1 A-GPS update file (NMT_14A.ee): https://downloadcenter.nikonimglib.com/en/download/fw/112.html | |
Nikon Coolpix P900/S9900/S9700/S9500/S810c/S800c/AW130/AW120/AW110s/AW110/W300 A-GPS update file (NMT_14A.ee): https://downloadcenter.nikonimglib.com/en/download/fw/112.html | |
Nikon Coolpix P610 A-GPS update file (NSO_28A.ee): https://downloadcenter.nikonimglib.com/en/download/fw/131.html | |
Nikon Coolpix P520/P510/P330 A-GPS update file (NML_28A.ee): https://downloadcenter.nikonimglib.com/en/download/fw/111.html | |
Nikon Coolpix S9300/AW100s/AW100 A-GPS update file (NCS_07A.ee): https://downloadcenter.nikonimglib.com/en/download/fw/110.html | |
#> | |
# Check if the computer is connected to the Internet # Credit: ps1: "Test Internet connection" | |
If (([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet) -eq $false) { | |
$empty_line | Out-String | |
Return "The Internet connection doesn't seem to be working. Exiting without downloading any files." | |
} Else { | |
$continue = $true | |
} # else | |
# Set the progress bar variables ($id denominates different progress bars, if more than one is being displayed) | |
$activity = "Downloading the Nikon A-GPS file" | |
$status = " " | |
$task = "Setting Initial Variables" | |
$total_steps = 6 | |
$activities = 5 | |
$task_number = 0.2 | |
$step = 1 | |
$id = 1 | |
# Update the progress bar | |
$activity = "Downloading the Nikon A-GPS update file - Step $step/$activities" | |
Write-Progress -Id $id -Activity $activity -Status $status -CurrentOperation "Reading $source" -PercentComplete (($step / $total_steps) * 100) | |
$empty_line | Out-String | |
# Get the download link URL | |
$data = (New-Object System.Net.WebClient).DownloadString("$source") | |
$regex = $data -match "P=\w+&R=\w+&L=\w+&O=\w+" | |
$keys = ($matches[0]).Split("&") | |
$part_1 = $keys[3].Split("=")[-1] | |
$part_2 = $keys[2].Split("=")[-1] | |
$part_3 = $keys[1].Split("=")[-1] | |
$part_4 = $keys[0].Split("=")[-1] | |
$url = [string]$base + $part_1 + $part_2 + $part_3 + $part_4 + '/' + $filename | |
# Set the download parameters for the Nikon A-GPS Update File (NMT_14A.ee) | |
[System.Uri]$download_uri = New-Object System.Uri "$url" | |
$download_url = $download_uri.AbsoluteUri | |
# Update the progress bar | |
$step++ | |
$activity = "Downloading the Nikon A-GPS update file - Step $step/$activities" | |
Write-Progress -Id $id -Activity $activity -Status $status -CurrentOperation "Purging old versions of NMT_14A.ee from $save_location" -PercentComplete (($step / $total_steps) * 100) | |
# Purge any existing old NMT_14A.ee files | |
If ((Test-Path $save_location -PathType 'Leaf') -eq $true) { | |
Write-Verbose "Deleting $save_location" | |
Remove-Item -Path "$save_location" -Force | |
} Else { | |
$continue = $true | |
} # else | |
# Update the progress bar | |
$step++ | |
$activity = "Downloading the Nikon A-GPS update file - Step $step/$activities" | |
Write-Progress -Id $id -Activity $activity -Status $status -CurrentOperation "Downloading the Nikon A-GPS file from $url" -PercentComplete (($step / $total_steps) * 100) | |
# Download the Nikon A-GPS Update File | |
try | |
{ | |
$download_plugin = New-Object System.Net.WebClient | |
$download_plugin.DownloadFile($url, $save_location) | |
} | |
catch [System.Net.WebException] | |
{ | |
Write-Warning "Failed to access $url" | |
$empty_line | Out-String | |
Return "Exiting without downloading the file." | |
} | |
Start-Sleep -s 1 | |
# Close the progress bar | |
$step = 6 | |
$activity = "Downloading the Nikon A-GPS update file - Step $step/$activities" | |
Write-Progress -Id $id -Activity $activity -Status $status -CurrentOperation "Finished downloading the Nikon A-GPS file." -PercentComplete (($step / $total_steps) * 100) -Completed | |
# Display basic stats in console | |
If ((Test-Path $save_location) -eq $true) { | |
# Find out how long the script took to complete | |
$file_is_downloaded = $true | |
$end_time = Get-Date | |
$runtime = ($end_time) - ($start_time) | |
If ($runtime.Days -ge 2) { | |
$runtime_result = [string]$runtime.Days + ' days ' + $runtime.Hours + ' h ' + $runtime.Minutes + ' min' | |
} ElseIf ($runtime.Days -gt 0) { | |
$runtime_result = [string]$runtime.Days + ' day ' + $runtime.Hours + ' h ' + $runtime.Minutes + ' min' | |
} ElseIf ($runtime.Hours -gt 0) { | |
$runtime_result = [string]$runtime.Hours + ' h ' + $runtime.Minutes + ' min' | |
} ElseIf ($runtime.Minutes -gt 0) { | |
$runtime_result = [string]$runtime.Minutes + ' min ' + $runtime.Seconds + ' sec' | |
} ElseIf ($runtime.Seconds -gt 0) { | |
$runtime_result = [string]$runtime.Seconds + ' sec' | |
} ElseIf ($runtime.Milliseconds -gt 1) { | |
$runtime_result = [string]$runtime.Milliseconds + ' milliseconds' | |
} ElseIf ($runtime.Milliseconds -eq 1) { | |
$runtime_result = [string]$runtime.Milliseconds + ' millisecond' | |
} ElseIf (($runtime.Milliseconds -gt 0) -and ($runtime.Milliseconds -lt 1)) { | |
$runtime_result = [string]$runtime.Milliseconds + ' milliseconds' | |
} Else { | |
$runtime_result = [string]'' | |
} # Else (if) | |
If ($runtime_result.Contains(" 0 h")) { | |
$runtime_result = $runtime_result.Replace(" 0 h"," ") | |
} If ($runtime_result.Contains(" 0 min")) { | |
$runtime_result = $runtime_result.Replace(" 0 min"," ") | |
} If ($runtime_result.Contains(" 0 sec")) { | |
$runtime_result = $runtime_result.Replace(" 0 sec"," ") | |
} # if ($runtime_result: first) | |
# Display the runtime in console | |
$timestamp_end = Get-Date -Format HH:mm:ss | |
$end_text = "$timestamp_end - The Nikon A-GPS file has been downloaded to $save_location" | |
Write-Output $end_text | |
$empty_line | Out-String | |
$runtime_text = "The procedure took $runtime_result." | |
Write-Output $runtime_text | |
$empty_line | Out-String | |
} Else { | |
$file_is_downloaded = $false | |
$error_text = "Didn't download any files." | |
Write-Output $error_text | |
$empty_line | Out-String | |
} # else | |
# [End of Line] | |
<# | |
_____ | |
/ ____| | |
| (___ ___ _ _ _ __ ___ ___ | |
\___ \ / _ \| | | | '__/ __/ _ \ | |
____) | (_) | |_| | | | (_| __/ | |
|_____/ \___/ \__,_|_| \___\___| | |
http://powershell.com/cs/blogs/tips/archive/2011/05/04/test-internet-connection.aspx # ps1: "Test Internet connection" | |
_ _ | |
| | | | | |
| |__| | ___ _ __ ___ ___ | |
| __ |/ _ \| '_ ` _ \ / _ \ | |
| | | | (_) | | | | | | __/ | |
|_| |_|\___/|_| |_| |_|\___| | |
https://gist.github.com/auberginehill/e649d84b695dc0e19c365bdbd9bf511a | |
Short URL: https://tinyurl.com/yau2wzkh | |
#> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Updating the A-GPS File (Nikon Coolpix P900/S9900/S9700/S9500/AW130/AW120/AW110s/AW110/W300)
Expiry Dates
www