Last active
August 29, 2015 14:22
-
-
Save blonkm/6b9139b071297c50671c to your computer and use it in GitHub Desktop.
Get only last revision from a Schoology submissions download
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
# (c) Michiel van der Blonk | |
# blonkm@gmail.com | |
# @name SchoologyGetLatestSubmissions.ps1 | |
# @date 2015-06-12 | |
# @description Get only last revision from a Schoology submissions download | |
# @notes copies files to a new folder on the destination named schoology_<date> | |
# @args | |
# path defaults to current directory | |
# destination defaults to desktop | |
# allow scripts (you can open powershell as administrator and run this command too): | |
# Set-ExecutionPolicy RemoteSigned | |
# or you can run from command line using: | |
# powershell -ExecutionPolicy Bypass -file SchoologyGetLatestSubmissions.ps1 | |
Param ( | |
$path = ".", | |
$destination = "desktop" | |
) | |
if ($destination -eq "desktop") { | |
$destination = [Environment]::GetFolderPath("Desktop") | |
} | |
$now = $(get-date -f MM-dd-yyyy_HH_mm_ss) | |
$copies = md -Path $destination"\schoology_"$now -Force | |
$d = $path | |
# get all student folders | |
ls $d | where {$_.Attributes -match 'Directory'} | % { | |
# get the last revision | |
$student = $_.Name | |
ls -Path $_.FullName | sort LastWriteTime | select -last 1 | % { | |
# get files in this folder | |
ls -Path $_.FullName | Where-Object { ! $_.PSIsContainer } | % { | |
# copy files to desktop folder | |
$extension = $_.extension | |
Copy-Item $_.FullName $copies"\"$student$extension | |
Echo $_.FullName | |
} | |
} | |
} | |
Echo "Completed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment