rename tv show to file name with the following script

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
phairplay
Newbie
Newbie
Posts: 29
Joined: April 30th, 2014, 4:39 pm

rename tv show to file name with the following script

Post by phairplay »

Hi guys,

I'm getting increasing tv shows with random tiles and would really like your help resolve this issue which would keep my wife happy when I'm away for work.

most of the shows shes watches are watched and deleted, therefore I had the following script created for me

Code: Select all

@echo off

for /f "tokens=*" %%c in ('dir/b/a-d %1 ^| find /v /c "::"') do set filecount=%%c

if %filecount% LEQ 5 (
cd /d %1
for /f "tokens=*" %%f in ('dir /a-d /b') do if not exist "..\%%f" ( 
echo Moving %%f...
move "%%f" ".."
)
cd ..
echo Deleting folder...
rd %1
) else (
echo To many files to move, aborting...
)
this downloads the and removed the required file from it's folder and deletes the unwanted folder.

how do I use this and rename the file at the same time?

thanks
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: rename tv show to file name with the following script

Post by shypike »

Rename the file to what?
What's the relation between the name and your script?
phairplay
Newbie
Newbie
Posts: 29
Joined: April 30th, 2014, 4:39 pm

Re: rename tv show to file name with the following script

Post by phairplay »

I'm looking for something that will rename the file to the name of the nzb
As I'm getting a lot recently that are a random set of numbers and letters.

I was wondering if this could be added to the script that dumps all my tv shows into one folder for easy viewing
mrg9999
Newbie
Newbie
Posts: 3
Joined: December 9th, 2012, 5:51 am

Re: rename tv show to file name with the following script

Post by mrg9999 »

I use this powershell I found. Change extension to required one.
###########################################################
# AUTHOR : Marius @ Hican - http://www.hican.nl - @hicannl
# DATE : 23-04-2012
# COMMENT : This script renames all .mkv files to the
# name of the .mkv parent folder recursively,
# extended with an increasing number.
# Put the script in the root of the folders'
# parent folder.
# NOTE: This script can also be used for renaming
# other / multiple files, just adjust the filter!
###########################################################
$path = Split-Path -parent $MyInvocation.MyCommand.Definition

Function renameFiles
{
# Loop through all directories
$dirs = dir $path -Recurse | Where { $_.psIsContainer -eq $true }
Foreach ($dir In $dirs)
{
# Set default value for addition to file name
$i = 1
$newdir = $dir.name + "_"
# Search for the files set in the filter (*.mkv in this case)
$files = Get-ChildItem -Path $dir.fullname -Filter *.mkv -Recurse
Foreach ($file In $files)
{
# Check if a file exists
If ($file)
{
# Split the name and rename it to the parent folder
$split = $file.name.split(".mkv")
$replace = $split[0] -Replace $split[0],($newdir + $i + ".mkv")

# Trim spaces and rename the file
$image_string = $file.fullname.ToString().Trim()
"$split[0] renamed to $replace"
Rename-Item "$image_string" "$replace"
$i++
}
}
}
}
# RUN SCRIPT
renameFiles
"SCRIPT FINISHED"
phairplay
Newbie
Newbie
Posts: 29
Joined: April 30th, 2014, 4:39 pm

Re: rename tv show to file name with the following script

Post by phairplay »

That's helpful thank you but I have both mkv and mp4s that go through the same issue
Post Reply