Search This Blog

Thursday, February 18, 2016

Fixing a long annoying issue Plex + FireFly + DVD Order



Download DVDOrderAgent.bundle from https://github.com/HuggableSquare/DVDOrderAgent.bundle

Follow steps in this post
1) Stop plex server.
2) Copy DVDOrderAgent.bundle,zip to plug in folder
    Path ~ C:\Users\\AppData\Local\Plex Media Server\Plug-ins
3) Extract  DVDOrderAgent.bundle,zip  to here
    Delete zip file
4) Start Plex server
5) In Plex web app,  go to a TV show - not a season page, the main page for the show - click the ellipsis (...) on the left and select "Fix Incorrect Match". Click on the "Auto Match" drop-down menu, and select "TheTVDBdvdorder". The metadata will be updated with the correct alternate order.
Episode order is fixed!!!

Monday, February 8, 2016

Useful Batch Files




Batch File Copy  full file names for all files in folder and sub folders to text file.

(replace &gt with )


dir C:\Data\Documents\*.* /b /s /a:-D >  C:\Documents.txt





Batch File: Copy just file name of files in folder to text file:
(replace &gt with )


dir C:\Data\Documents\*.* /o-n-d /b  >  C:\Files.txt

Some Useful powershell scripts


Power shell scripts:

#1 Read file names from csv file using pipe delimiter and copy files to with new name to new destination

C:\Temp\finals.csv - csv file
FileName - source file
NewFileName - new name and destination for file

$csv = Import-Csv L:\DataMigration\CalRad\Reports_finals.csv '|' -Header FileName,NewFileName
foreach ($line in $csv) {    If ((Test-Path $line.FileName)){ Copy-Item -path $line.FileName -Destination $line.NewFileName } }



#2  Get all of the pdf full file paths
      execute application using full file path as a command argument.


  $items = Get-ChildItem "L:\DataMigration\CalRad\LegacyData\LegacyReports\Scanned_Docs" -Filter *.pdf 
  foreach ($item in $items) { L:\DataMigration\CalRad\PDFToImage\PDFToImages.exe $item.FullName 140}


#3) import csv file pipe delimited with 4 columns
      copy file to new location using 3rd parameter as source location and 4th parameters as destination path and file name.


$csv = Import-Csv L:\DataMigration\CalRad\LegacyData\LegacyReports\Scanned_Docs.csv '|' -Header Accession,Type,FileName,NewFileName
   foreach ($line in $csv) {    If ((Test-Path $line.FileName)){ Copy-Item -path $line.FileName -Destination $line.NewFileName } }

Tuesday, December 8, 2015

Unexpected results Min() Max() results from SELECT TOP 100 sql statement

Testing a solution to find min() max() of 100 rows returned from a query provided some interesting results.

SELECT  min(x.radar_queue_key), max(x.radar_queue_key)
FROM (SELECT TOP 100 radar_queue_key FROM z_radar_queue WHERE radar_group_Code='SFV OTS' ORDER BY radar_queue_key asc) as x

Results:867 966

SELECT  min(x.radar_queue_key), max(x.radar_queue_key)
FROM (SELECT TOP 100 radar_queue_key FROM z_radar_queue WHERE radar_group_Code='SFV OTS') as x

Results:867 1879

SELECT  min(radar_queue_key), max(radar_queue_key)
FROM  z_radar_queue 
WHERE radar_group_Code='SFV OTS'

867 1879


What is interesting is that actual Min() =867 and actual max() =966 for the Top 100 rows.

Both of these queries return exactly the same rows in exactly the same order (even when flushing data cache) because radar_queue_key is the primary key on the table.



SELECT TOP 100 radar_queue_key FROM z_radar_queue WHERE radar_group_Code='SFV OTS' ORDER BY radar_queue_key asc

SELECT TOP 100 radar_queue_key FROM z_radar_queue WHERE radar_group_Code='SFV OTS'

Value of 1879 does not appear in either result set. The execution is completely different if the sql statements are used as a subquery.

Lesson here is always use an order by clause when fetching rows for aggregation + TOP xxxx

Saturday, October 31, 2015

Setting up SQLite and EF6

Here is something that is more difficult than it should be.

My answer on StackOverflow:

My environment:

VS2013 Pro
Entity Framework 6: version 6.1.3
Sqlite .net library: System.Data.SQLite versions: 1.093 - 1.095

Do not use Nuget Manager to download