Coder Social home page Coder Social logo

macdonaldr93 / rename-looney-tunes-gold-collection-plex Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 3.0 31 KB

Rename Looney Tunes Gold Collection files for Plex <S0E0 - Episode Name.ext>

License: GNU General Public License v3.0

JavaScript 100.00%
plex plex-media-server

rename-looney-tunes-gold-collection-plex's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rename-looney-tunes-gold-collection-plex's Issues

Powershell version

Here's a powershell version that I made that if they are named properly it will add the season and episode, so I wanted to share. Please note, for it to work, the column names must be single words renamed to "Number" "Name" "Aired"

cls
#$CSVPath = Read-Host "Please enter CSV path"
#$directory = Read-Host "Please enter directory path"
$directory = "Z:\Television\Looney Tunes"
cd $directory

$CSVPath = "Z:\Television\Looney Tunes\tvdb.csv"    
"CSV Path: $CSVPath"

$csv = Import-CSV $CSVPath
#$csv | Select-Object Number, Name, Aired | Format-Table

$csv | ForEach-Object{

    $name = $($_.Name)
    $number = $($_.Number)

    Get-ChildItem *$name*|%{
        "Match found for $name"
        "$name info:"
        "number: $number"        

        $pos = $number.IndexOf("x ")
        $episode = [int]$number.Substring($pos+2)
        
        if($episode -lt 10)
        {
            $episode = "0$episode"
        }

        "Episode: $episode"
         
        $fullName = $($_.FullName) 

        "childItemName:  $fullName"
        $containingFolder = Split-Path -Path $fullName
        "Containing Folder: $containingFolder"
        $fileName = Split-Path -Path $fullName -Leaf -Resolve

        "Filename: $fileName"

        $season = $number.substring(0, 4)
        "Season: $season"
        
        $preparedStatement = [Regex]::Escape("Looney Tunes - ")
        $newFileName = $fileName.replace("Looney Tunes - ", "Looney Tunes - "+"s$season"+"e$episode - ")        

        $destFile = $containingFolder + "\Season $season\$newFileName"

        "Dest: $destFile"
        $destFolder = Split-Path -Path $destFile
        "Dest folder: $destFolder"
        
        If(!(test-path $destFolder))
        {
              New-Item -ItemType Directory -Force -Path $destFolder
        }

        Move-Item -Path $fullName -Destination $destFile
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.