mdrabble Posted July 18, 2018 Posted July 18, 2018 (edited) The "powers that be", have in their infinite wisdom decided to switch to a 2 week timetable from September. They have asked if I can display Week A or Week B on the desktop depending which week we are in. Anyone ever done this or know of a "simple" way to do this? Cheers Edited July 18, 2018 by mdrabble
sted Posted July 18, 2018 Posted July 18, 2018 put 2 wallpapers somewhere on server called a.jpg & b.jpg. use gpo etc to set everyones wallpaper to c.jpg. on a server have a scheduled task that runs on sunday every 4 weeks that does copies a.jpg to c.jpg and another in the 2 weeks between that copies b.jpg to c.jpg bit of a cludge but should work
mdrabble Posted July 19, 2018 Author Posted July 19, 2018 I have managed to sort the browser home pages so they can display the correct week - using this thread - http://www.edugeek.net/forums/coding/92312-display-week-1-week-2-joomla-intranet-page.html Now..... if I can find a script that looks up the week and can rename files automatically then that would be amazing :-D
cw222 Posted July 19, 2018 Posted July 19, 2018 (edited) Havn't got the solution (sorry) however its something very doable in python with the datetime library and OS or shutil depending on what you want: Some cobbled together pseudopythonycode #name of library import [color=#0000FF][b]datetime[/b][/color] import os #getting current date now [color=#666666]=[/color] datetime[color=#666666].[/color]datetime[color=#666666].[/color]now() #current date to string now. day + now.month + now.year to now.string #comparing string to csv/text file / array / list Loop now.string to compare against lines in listA{ If now.string present in listA: #rename file os.rename('filea' , 'fileb') Else: #rename file os.rename('fileb' , 'filea') } Edited July 19, 2018 by cw222 1
jthompson Posted July 19, 2018 Posted July 19, 2018 put 2 wallpapers somewhere on server called a.jpg & b.jpg. use gpo etc to set everyones wallpaper to c.jpg. on a server have a scheduled task that runs on sunday every 4 weeks that does copies a.jpg to c.jpg and another in the 2 weeks between that copies b.jpg to c.jpg bit of a cludge but should work Doing it this way, you'd probably need more detailed scheduling of the triggers to account for half terms, etc. where the A/B rotation skips an odd number of weeks (and then rework them all next year).
mdrabble Posted July 19, 2018 Author Posted July 19, 2018 (edited) Think I have cracked it! Powershell Code #Get the Current Week $today = Get-Date $delta = $today.DayOfWeek.value__ - 1 #Import CSV $CheckDate = $today.AddDays(-$delta).Date $data = Import-Csv weeks.csv | Where-Object { ($_."WeekDate" -as [DateTime]) -eq $CheckDate } #Rename Wallpaper if ($data.WeekAB -eq "Week A") { Copy-Item "\\server\netlogon\Wallpapers\Staff_WeekA.jpg" "\\server\netlogon\Wallpapers\Staff.jpg" Copy-Item "\\server\netlogon\Wallpapers\Student_WeekA.jpg" "\\server\netlogon\Wallpapers\Student.jpg" Write-Host "Week A" } else { Copy-Item "\\server\netlogon\Wallpapers\Staff_WeekB.jpg" "\\server\netlogon\Wallpapers\Staff.jpg" Copy-Item "\\server\netlogon\Wallpapers\Student_WeekB.jpg" "\\server\netlogon\Wallpapers\Student.jpg" Write-Host "Week B" } Then just need to schedule a task to run once on a Monday at silly O'clock and the BGInfo does the rest! Edited July 19, 2018 by mdrabble
cw222 Posted July 20, 2018 Posted July 20, 2018 Nice:)! Looks the same logic as the python pseudocode but powershell seems like the better option.
mdrabble Posted July 20, 2018 Author Posted July 20, 2018 Yep same logic - opted for powershell as figured it may be more useful for anyone who wanted to use the script
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now