Skip to content

Instantly share code, notes, and snippets.

@blonkm
Last active August 29, 2015 14:22
Show Gist options
  • Save blonkm/6b9139b071297c50671c to your computer and use it in GitHub Desktop.
Save blonkm/6b9139b071297c50671c to your computer and use it in GitHub Desktop.
Get only last revision from a Schoology submissions download
# (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