# Robust Folder Manipulation - folders.tcl



## rbautch

Here is a script that will:

1) Add shows to a folder

2) Create new folders (See here for details).

3) Remove shows from a folder

4) Rename a folder

5) Duplicate the directory structure from your Tivoserver PC so that shows automatically get put into folders after they transfer to your Tivo. See here for more details.

6) List all folders and their contents

7) List orphan shows that aren't in a folder

6) Change the attributes of all shows in a particular folder, such as the Original Air Date, Actors, Title, or Episode Description.

8) Reorder shows based on original air date or showing date.

9) Reorder shows in a folder using season/episode notation. So show.S02E12.mpg appears before show.S03E09.mpg in NPL.

10) Make show titles "nice". This includes:
- If the show does not have an episode title, set the episode title equal to the show title, and then change the show title to equal the series title.
- Strip off file extensions from episode titles. 
- Remove tivo formatting from tivoserver insertions - i.e. strip off braces. 
- Strip off torrent formatting, so "My.Boys.S01E18.DSR.XviD-SYS.mpg" gets changed to "My Boys" Season episode info then gets added to show description.

11) Automatically match shows with folders. Can run from cron to organize shows periodically. More information here.

Here's an example of what features 9 and 10 do:
Before:









After:









Note that the episodes have been ordered according to the season/episode designation, the season/episode information has been moved to the episode description, formatting and extensions have been stripped off, and periods and underscores have been converted to spaces.

Current version is 2.9


----------



## crxrocks

Thanks for all of the hard work you do, rbautch. 

I copied over the new script, used dos2unix to strip out the crap, changed the permissions so that I could execute it and then ran the script.

I had a folder created called "Doctor Who" and wanted to rename it to "Kids Shows". I chose #2 and then put in the old folder and new folder names. The script did a CR and then just sat at the next line for about 5 minutes before my zippered DirecTivo rebooted.

Any ideas or troubleshooting I can do for you?


----------



## rbautch

I couldn't duplicate your error. Try downloading the file again, try a different folder, try a different tivo, and try downloading it from the files section of DDB (just in case the zipping process introduced something).


----------



## crxrocks

rbautch said:


> I couldn't duplicate your error. Try downloading the file again, try a different folder, try a different tivo, and try downloading it from the files section of DDB (just in case the zipping process introduced something).


Downloaded the tcl file directly from DDB and tried different folder names. I don't have another hacked tivo at the moment so I cannot try on another tivo. I will try it again in a couple of weeks once I get to work on my other tivo.


----------



## unclemoosh

I have downloaded and used it without a problem. It works great. Thanks for your contribution!


----------



## Soapm

I have about 100 MASH episodes and am still keeping all I can. Unfortunately the list in the folder based on the date they were recorded. Will this allow me to sort them by original air date? Can this be a possible future enhancement?


----------



## Soapm

Hey rbautch, you know how you gave us shortcut commands like TWP to launch Tivo WebPlus and TWPRS to restart it. How do I add "folders" to launch this application?


----------



## Soapm

Also, I tried to resort my MASH folder by episode using option 6f (Reorder episodes based on season/episode information in show title) and got this error...

Found a folder named "M*A*S*H" containing 126 episodes.
no such object: {CONFLICT err=0x30019}
while executing
"dbobj $program get Title"
(procedure "get_objects_byfsid" line 21)
invoked from within
"get_objects_byfsid"
("foreach" body line 2)
invoked from within
"foreach fsid $targetlist {
get_objects_byfsid
# Does show have Sxx Exx designation?
# set episodetitle bigbrotherS04E09.04; if { [rege..."
("uplevel" body line 2)
invoked from within
"uplevel $body"
invoked from within
"transaction {uplevel $body}"
(procedure "RetryTransaction" line 5)
invoked from within
"RetryTransaction {
foreach fsid $targetlist {
get_objects_byfsid
# Does show have Sxx Exx designation?
# set episodetitle bigbroth..."
invoked from within
"if {$selection == 1} {
puts ""
set targetfolder [ askuser "Enter the name of the TARGET FOLDER you want to add shows to
: " ]
############# Find ..."
(file "/enhancements/folders.tcl" line 318)


----------



## rbautch

Soapm said:


> Hey rbautch, you know how you gave us shortcut commands like TWP to launch Tivo WebPlus and TWPRS to restart it. How do I add "folders" to launch this application?


Look in a file called .profile in the root directory, and you'll see how the shortcut commands work. Note that this is a hidden file, and you can't see it with the standard ls command.


----------



## rbautch

Looks like your MASH program might have a title set to "{CONFLICT err=0x30019}". Or possibly the script set the title to that on a previous run. Please post a screen capture from this show's object in MFS. You can get to it in TWP by selecting the MFS option, then recording, then nowshowingbybuckettitle, then select the MASH episode, the select showing, then select program.


----------



## Soapm

Here is one of them, I was under the impression this would resort the entire folder.. Are you saying it only does one episode at a time?

Program 215168/11 {
ServerVersion = 45
TmsId = EP0027100209
Title = M*A*S*H
Series = 7825/-1
Description = {Charles is permanently assigned to the 4077th.}
DescLanguage = English
ShowType = 5
SourceType = 2
EpisodeTitle = {Fade Out, Fade In}
Actor = Alda|Alan Morgan|Harry {Stiers|David Ogden} Farrell|Mike Burghoff|Gary Swit|Loretta Farr|Jamie Christopher|William
GuestStar = Lough|James Singer|Raymond Stovall|Tom Hurst|Rick Symonds|Robert Flatley|William Hiroshige|Kimiko Burns|Joseph James|Barbara Poss|Ray {Pettee Jr.|Robert Holmes}
Genre = 91 115 1002
ColorCode = 4
EpisodeNum = 0
IsEpisode = 1
OriginalAirDate = 2819 (9/20/1977)
ServerId = 26702
Version = 1
IndexPath = /Server/26702
}


----------



## Soapm

rbautch said:


> Look in a file called .profile in the root directory, and you'll see how the shortcut commands work. Note that this is a hidden file, and you can't see it with the standard ls command.


Do I have to restart the Tivo before this works?


----------



## Soapm

Looking closely at a lot of the files using the Info button on the Tivo remote, I see none of the shows so far have a season setting and the majority of the episode number set to 0. Could this be part of the problem?

One thing I did notice is all of them, no matter which channel they were recorded from has the original air date. Is it possible to make the script sort by original air date?

Edit to also add, could it be that this information (season and episode) is not in the actual shows title?


----------



## rbautch

Soapm said:


> Here is one of them, I was under the impression this would resort the entire folder.. Are you saying it only does one episode at a time?


It sorts the entire folder, but the title of the show or the episode has to have season/episode info in the name. The script looks for this information in SxxEyy format, so in order for it to work for you, you'd have to change the episode title to "Charles is permanently assigned to the 4077th_S02E12", assuming this was the 12th episode from the second season. Sorting by the original air date shouldn't be too hard, maybe I'll add it in a future version. Still looking into the error you got. Might be related to asterisks in the title.


----------



## bengalfreak

After installing the robust folders.tcl. I do not get an option to reorder the shows in a folder using season and episode notation. What gives?


----------



## rbautch

bengalfreak said:


> After installing the robust folders.tcl. I do not get an option to reorder the shows in a folder using season and episode notation. What gives?


Use option 6. That gives you another menu of stuff you can change within a folder.


----------



## bengalfreak

Gotcha. 

Thanks.


----------



## Soapm

rbautch, are you still considering making the original air date an option? It would sure save me from having to rename over 200 shows.


----------



## rbautch

Yes.


----------



## StanSimmons

Love the folders.tcl !

Is there any way to create new folders, rather than renaming existing folders?


----------



## rbautch

StanSimmons said:


> Love the folders.tcl !
> 
> Is there any way to create new folders, rather than renaming existing folders?


Thanks Stan. Sorry, no way that I know to create a new folder. I and others have tried.


----------



## StanSimmons

Thanks, I've been just recording a few minutes of a show, twice. This creates a folder that I then change the name and move shows into.


----------



## bengalfreak

I know you can now setup a crond job to rename folders regularly, but one thing I do is use football games to create folders whose name will not change, I just pick an NFC team versus an AFC team. Those two teams should not play again for three years, and even then if the home city is different, the program will have a different name. Of course, this only works during football season.


----------



## msommer

Hey Russ check this one out.. 

I used the new folders.tcl to rename some shows in a folder just to get a feel for the new script. The folder contained three shows of the series "Build it Bigger". I changed the name of the series from "Build it Bigger" to "test", and then changed the content description of the episode for each to "testing". The folder was still named "Build it Bigger" and the three episodes were renamed to "test" with the description "testing". When I MRV one of the shows to another box, the transferred show reverts back to the original series name and description. OK so far so good...

Now for the weird part; when those episodes I made changes to show up in the live guide data downloaded from the sat, the episode name and description are "test" with the show description as "testing"!!! Other episodes of "Build it Bigger" show up in the guide correctly, but every time the episodes that I changed show up in the live guide, they show the modified description!!

Could this have something to do with a cron job on this box?

I have rebooted and the guide still shows the changed data....

By the way, the script is great!!!


----------



## rbautch

Most of this is expected behavior except for the folder retaining its original name. I'll record a few episodes of Build It Bigger to see if I can duplicate your results. Did you record it on Discovery or Sci-fi?


----------



## RandCfilm

msommer said:


> Now for the weird part; when those episodes I made changes to show up in the live guide data downloaded from the sat, the episode name and description are "test" with the show description as "testing"!!! Other episodes of "Build it Bigger" show up in the guide correctly, but every time the episodes that I changed show up in the live guide, they show the modified description!!


As rbautch said, the guide data is normal. If you changed the description for the series on Discovery then the guide data for Discovery will reflect those changes. The guide data for Sci-fi would not change, provided you had changed no information linked to the series from Sci-fi.


----------



## msommer

rbautch said:


> Most of this is expected behavior except for the folder retaining its original name. I'll record a few episodes of Build It Bigger to see if I can duplicate your results. Did you record it on Discovery or Sci-fi?


I recorded the series on the SCI channel. I tried it again with the same results. The folder name remained the same. Using the latest version of Zipper with 6.2 and BTUx9's change to 6.2a.


----------



## rbautch

Can you change the name of other folders? Are you looking for the change in your NPL or in TivoWebPlus?


----------



## msommer

rbautch said:


> Can you change the name of other folders? Are you looking for the change in your NPL or in TivoWebPlus?


Yes, I can change names of other folders. I am looking in the NPL.

Update: The folder has now changed to the new name I gave it. It appears that the folder changes back to the original "Build it Bigger" name everytime a new episode records. So it looks like the name change I give to the folder stays until a new episode records. I am answering yes to the prompt to make the change permanent.

Does it sound like a problem with cron? I have noticed that on this box when I make folder name changes, they always revert back to the original name. Of course this may be normal behavior, I don't know.

Mark


----------



## Joybob

Since you mention Torrent episodes:

My local cable co. won't show House M.D. in High Def so can I get it off a torrent site and upload it to my S3 once they enable video transfers? Is there a particular video codec I should search for?


----------



## rbautch

Joybob said:


> Since you mention Torrent episodes:
> 
> My local cable co. won't show House M.D. in High Def so can I get it off a torrent site and upload it to my S3 once they enable video transfers? Is there a particular video codec I should search for?


You have to hack your tivo first.


----------



## rbautch

msommer said:


> Yes, I can change names of other folders. I am looking in the NPL.
> 
> Update: The folder has now changed to the new name I gave it. It appears that the folder changes back to the original "Build it Bigger" name everytime a new episode records. So it looks like the name change I give to the folder stays until a new episode records. I am answering yes to the prompt to make the change permanent.
> 
> Does it sound like a problem with cron? I have noticed that on this box when I make folder name changes, they always revert back to the original name. Of course this may be normal behavior, I don't know.
> 
> Mark


Reverting back to the original name when a new episode records is normal behavior, although for me it doesn't happen immediately. It's also possible that downloading guide data triggers the reversion back to the original name. The cron job should be renaming the folder from the original name back to what you named it. Look at your crontab to make sure that's happening, and that the cron job is occurring frequently enough to make the name change stick - I think I set it run once per day, but you can set it run at any frequency you like. Most people don't encounter this issue because the folder name change is used as a kludgey way to create a new folder. I usually find a show that I will never watch, and then rename to something like "movies", and store all my movies there.


----------



## bengalfreak

I got some really strange behavior from the folders.tcl script. When choosing option 7, 'make episode titles in all folders nice, it moved everything from the "Chuck" folder to the "Heroes" folder. After it was finished, I have episodes of both shows in the "Heroes" folder. Another thing, prior to selecting option 7, "Chuck" would not appear in the list of folders when selecting option four. Weird.


----------



## rbautch

bengalfreak said:


> I got some really strange behavior from the folders.tcl script. When choosing option 7, 'make episode titles in all folders nice, it moved everything from the "Chuck" folder to the "Heroes" folder. After it was finished, I have episodes of both shows in the "Heroes" folder. Another thing, prior to selecting option 7, "Chuck" would not appear in the list of folders when selecting option four. Weird.


Wierd indeed. Can you duplicate the behavior, or was this the only folder it happened on? If you can capture the folders.tcl output on such a folder it might help narrow down the issue. Have you renamed the "Chuck" or "Heroes" folder at any time?


----------



## MurrayW

Another weird thing with folders.

I made a "Movies" folder and moved all 60 of the movies I have recorded into this folder. From my TV, I went to this folder on my NPL and selected the movie I wanted to watch. I watched it to the end. Ididn't go through the credits or the couple of minutes of padding I added to the end so I never go the option to delete the show.

Next I pressed the TiVo button on my remote to take me back to the NPL with the intention of deleting this show I just watched. Pressing the TiVo button on my remote took me back inside of the Movies folder and I expected the show that I just watched to be the one that was ready to be selected...it wasn't. So I scrolled up and down through my 60 movies and couldn't find it. At this point I noticed that I had 59 movies in my folder so I thought this wasn't good, the show was automatically deleted without asking me if I wanted to delete it.

I left arrowed out of the Movies folder into my main NPL and the show I had just watched was now showing up in the main NPL list not inside a folder. I selected it and deleted it. Now this was not a big deal since I planned to delete it again, but if I had wanted to save it, I would have to move it back into the Movies folder.

Has anyone else seen this type of behavior?

thanks,
Murray


----------



## angra

rbautch said:


> Thanks Stan. Sorry, no way that I know to create a new folder. I and others have tried.


I have done this. It has been a long time since I developed the proof of concept. I am 99% sure that I am remembering correctly, and will send or upload code when I can.

edit: I can't find the proof of concept code, so I will have to reconstruct it. The basic approach is to have the program create a new wishlist, create a season pass based on the wishlist, associate the recording with the new ARWL, then remove the new ARWL/seasonpass and the new wishlist. The folder association sticks around even after the wishlist it derived from is gone.


----------



## bengalfreak

rbautch said:


> Wierd indeed. Can you duplicate the behavior, or was this the only folder it happened on? If you can capture the folders.tcl output on such a folder it might help narrow down the issue. Have you renamed the "Chuck" or "Heroes" folder at any time?


I'll try and duplicate it on Monday after another episode of Chuck records. Currently, I don't have a chuck folder so I can't play with it. And no, I have never renamed either folder. I don't mess with folders much. I only use the folders script when I miss a show and have to d/l it from bitorrent.


----------



## angra

Here is proof-of-concept code to associate a showing entry with a wishlist. This will create a folder in Now Showing if it does not exist, or move the entry to the folder if it exists.

New folder creation works as I described above, but I don't have the time right now to work it up.

p.s. I wrote this as a tivoweb module, but the user interface is not module friendly, so I never released it as a complete module. Anyone who's done module work should be able to decipher the input but if there is trouble, let me know....



Code:


# associate.itcl - copyright by me.  I will release under GPL v2 
# on request.  
#
# This is a proof of concept to associate a tivo recording (identified
# by fsid) with a Theme (wishlist) identified by FSID
#
# This software is provided without warranty and as-is.  Use
# at your own risk.  It will probably not work, destroy data on your
# tivo, and make your dog run away.

proc action_associate {chan path env} {
  global db
  global seasonpassdir

  eval $env
  
  set made 0
  puts $chan [html_start "Association"]
  
  if {$theme == 0} {
    RetryTransaction {
      set destobj [db $db openid $showing]
      dbobj $destobj remove ProgramSource
      puts $chan "Wishlist association removed succesfully!\n"
    }
  } else {
    RetryTransaction {
      set themeobj [db $db openid $theme]
      set showingobj [db $db openid $showing]
      if {[dbobj $themeobj type] != "Theme"} {
        puts $chan "Malformed input:Theme=$theme\n"
        return
      }
      if {[dbobj $showingobj type] != "Recording"} {
        puts $chan "Malformed input:Showing=$showing\n"
        return
      }
      set spobj [dbobj $themeobj get SeasonPass]
      if {$spobj != ""} {
        dbobj $showingobj set ProgramSource $spobj
      } else {
        set made 1
        set spobj [db $db create SeasonPass]                               
        dbobj $spobj set Type 3
        dbobj $spobj set Theme $themeobj
        dbobj $showingobj set ProgramSource $spobj
        set spfsid [dbobj $spobj fsid]
      }
    }
    puts $chan "Wishlist association completed\n"
  }
  if {$made == 1} {
    RetryTransaction {
      set spobj [db $db openid $spfsid]
      dbobj $spobj markasrubbish
    }
  }
}


----------



## Soapm

Soapm said:


> rbautch, are you still considering making the original air date an option? It would sure save me from having to rename over 200 shows.





rbautch said:


> Yes


Any luck with sorting by original air date? I now have a Hogan Hero folder plus my MASH that I would like to have sorted.

Great app by the way...


----------



## newkid

I downloaded folders.tcl (ver 1.9) and successfully moved several videos to a renamed folder. A few days later I noticed the folder name had changed back to the original name. When I re-ran "folders.tcl" from the telnet prompt I got the folders.tcl menu, but it would not recognize my input "2".

_Family-Rm-TiVo# folders.tcl
Running folders.tcl Version 1.9
Please select from the following:
1 Add show(s) to an existing folder.
2 Change the name of a folder.
3 Remove a show from a folder.
4 List all folders and folder IDs.
5 List all shows and recording IDs.
6 Change the attributes of all shows in a folder.
7 Make episode titles in all folders "nice".
Enter the number corresponding to the action you want to perform: 2

Error: You must enter 1, 2, 3, 4, 5, 6, or 7!_

Does anyone what would cause this, or how to make the folder names permanent? I don't understand why "folders.tcl" would work initially and then not recogize inputs.

Any help would be appreciated.


----------



## Da Goon

Your terminal settings are probably screwed up. Which terminal prog are you using?


----------



## newkid

Da Goon said:


> Your terminal settings are probably screwed up. Which terminal prog are you using?


I've been running it in telnet from the command prompt. Do I need to use something else? It worked originally.


----------



## Da Goon

newkid said:


> I've been running it in telnet from the command prompt. Do I need to use something else? It worked originally.


Windoze? If so, try 'unset crlf' before connecting to your box.


----------



## newkid

Da Goon said:


> Windoze? If so, try 'unset crlf' before connecting to your box.


Yes, thats what I've doing. Any other suggestions?


----------



## rbautch

Try using Tera Term.


----------



## newkid

rbautch said:


> Try using Tera Term.


Yes, that worked thank you.


----------



## newkid

newkid said:


> Yes, that worked thank you.


Update: After a few days (and after using Tera Term), the folders have reverted back to their original folder name.

I originally recorded 2 brief recordings titled "Tennis", and then renamed the "Tennis" folder to "MOVIES" using Tera Term. I answered yes to the prompt to make the change permanent. I have not recorded any other "Tennis" shows, any idea why it continues to revert back to the original name. I have this same behavior on 2 different DVR-40 units enhanced with Zipper.

Is there a cron setting I need to modify? Is so, how would I do that?

Update: When I view my folders/recordings in TivoWeb Plus, the folder is listed as "Movies" not "Tennis" -- but the NPL on the DVR-40 still reflects the folder name as "Tennis".


----------



## rbautch

Check your root file in the cron setup - you can do this by typing "root" at the bash prompt if you used my enhancement script or the Zipper. Make sure there is a cron job to periodically run folders.tcl and change the name back to movies. It should look like this:


Code:


20 9 * * * cd /enhancements; tivosh folders.tcl "Tennis" "Movies"

If it's in there okay, move on to 3 more troubleshooting steps: 1) Trying running the tivosh command from the cron entry above. 2) Make sure you are using the latest version of folders.tcl, and 3) Make sure your cron setup is working properly.


----------



## newkid

rbautch said:


> Check your root file in the cron setup - you can do this by typing "root" at the bash prompt if you used my enhancement script or the Zipper. Make sure there is a cron job to periodically run folders.tcl and change the name back to movies. It should look like this:
> 
> 
> Code:
> 
> 
> 20 9 * * * cd /enhancements; tivosh folders.tcl "Tennis" "Movies"
> 
> If it's in there okay, move on to 3 more troubleshooting steps: 1) Trying running the tivosh command from the cron entry above. 2) Make sure you are using the latest version of folders.tcl, and 3) Make sure your cron setup is working properly.


When typing root, the following is the end of the file:


> # End of crontab
> 20 9 * * * cd /var/tmp; tivosh folders.tcl "Tennis" "Movies"
> 20 9 * * * cd /var/tmp; tivosh folders.tcl "TnHennis" "Movies"
> 20 9 * * * cd /var/tmp; tivosh folders.tcl "Tennis" "Movies"
> 20 9 * * * cd /var/tmp; tivosh folders.tcl "Home Movies" "Work Movies"


Is it getting wiped out because its in the cd/var/tmp folder? How would it end up there if I used your script?

When I view the "root" file in enhancements it does not show the folders command


> # Sample below creates a test file and updates it with current time and date
> # every 5 minutes -- use this for troubleshooting.
> # m h dom mon dow	command
> */5 * * * *	date >> /var/log/cron.test.out
> 
> # Wipe the logs every Sunday night at 3:18am cst
> 18 9 * * 1 /busybox/wipelogs; echo "`date` logs wiped" >> /var/log/cronlog-main
> 
> # Run fakecall every night at 10:20pm cst
> 20 4 * * * tivosh /busybox/fakecall.tcl
> 
> # Delete the crond log files every 3 months
> 22 9 1 */3 * rm /var/log/cronlog-main; echo "`date` cron logs wiped">> /var/log/cronlog-main
> 
> # Delete cron.test.out every night at 3:24am cst
> 22 9 * * * rm /var/log/cron.test.out; echo "`date` cron.test.out deleted" >> /var/log/cronlog-main
> 
> # Weekly reboots. Cleans things out for better performance if you have several hacks running
> # Also restarts logs, and allows fakecall to reset the last successful call indicator,
> # so your Tivo won't call home (fakecall doesn't update mfs entries without a reboot).
> # This allows you to keep your phone line connected for callerID and PPV ordering.


Shouldn't 20 9 * * * cd /enhancements; tivosh folders.tcl "Tennis" "Movies" be in this root file in the enhancements folder?
I am using version 1.9 which I believe is the latest version


----------



## rbautch

It set up the cron jobs to change directories to the directory from which you originally ran the folders.tcl (/var/temp). That may be your problem. I suggest deleting those lines from your root file, then put the folders.tcl script somewhere where it wont be wiped (not var), rename the folders again, and finally check the root file again to make sure the new entries are there. The root file in the enhancements directory is not active, and not seen by cron. If you want to know where the active root file is, take a look in /.profile.


----------



## newkid

rbautch said:


> It set up the cron jobs to change directories to the directory from which you originally ran the folders.tcl (/var/temp). That may be your problem. I suggest deleting those lines from your root file, then put the folders.tcl script somewhere where it wont be wiped (not var), rename the folders again, and finally check the root file again to make sure the new entries are there. The root file in the enhancements directory is not active, and not seen by cron. If you want to know where the active root file is, take a look in /.profile.


When I telnet using Tera Term the initial default directory is "/var/temp"; I never thought to do a "dirs" to check my location. I didn't find "/.profile", but I did find "root" in "/var/spool/cron/crontabs". I deleted the lines using Notepad++ and placed it back in the same directory. The folders.tcl is located in the "/enhancements" directory. I ran "folders.tcl" from the "/enhancements" directory and changed my folders names using the script. When finished, I checked the "root" in "/var/spool/cron/crontabs" and it now has 20 9 * * * cd /enhancements; tivosh folders.tcl "Tennis" "Movies" as it should. Now I'll wait and see if it remains permanent.

Does this mean I should always run "folders.tcl" while in the "/enhancements" directory to prevent problems?

Thank you for your help in diagnosing the problem.


----------



## rbautch

Yes. I'd also run this command to see if it works:


Code:


tivosh folders.tcl "Tennis" "Movies


----------



## rbautch

Based on the code angra posted here, I added the capability to create new folders from scratch. This feature creates "wishlist folders" - the blue folders with a white star in the middle. The new script is attached to the OP. Thanks angra!

Usage: To create a folder, choose option 1. If the folder doesn't already exist, it will ask you if you want to create it.


----------



## StanSimmons

Once again proving that you "are the man!"


----------



## Soapm

rbautch, are you still considering making sort by the original air date an option? I now have all the Andy Griffith along with all MASH episodes that I would love to have sequenced by the tivo set original air date.


----------



## bengalfreak

rbautch

is there any way to copy several shows to a folder without having to rerun the script each time? Like adding several shows to a 'movies' folder.


----------



## rbautch

bengalfreak said:


> rbautch
> 
> is there any way to copy several shows to a folder without having to rerun the script each time? Like adding several shows to a 'movies' folder.


Depending on if the show is already on the tivo, or still on your PC, you can do this in a few ways:

1. If the movies are on your PC, create an xml file for each movie, and then transfer them with Tivoserver. I posted a cygwin script on DDB that will create xml files for all the shows in a folder on your pc, which is very convenient if you have 100 movies an want to transfer them all into a folder on your tivo. The only catch is that this won't yet work with folders you create using the new feature of folders.tcl (because they are wishlist folders), so you'll have to create or rename folders the old fashioned way.

2. If the shows are already on your tivo, keep in mind that the script looks for partial matches, so you can enter any part of the show name that is common to all the movies. For example if you had shows named Terminator 1, Terminator 2, and Terminator 3, just entering "Terminator", would move all the 3 shows to the folder. You can also use this tactic if the shows are on your PC and you don't want to mess with xml files. You just append some unique text to the end of each filename, like say "S01E01", then transfer all the shows to your tivo, then enter "S01E01" as the show name you want to move into a folder. Then you can use the "make nice" feature of folders.tcl to strip off the S01E01 from the show name.


----------



## rbautch

Soapm said:


> rbautch, are you still considering making sort by the original air date an option? I now have all the Andy Griffith along with all MASH episodes that I would love to have sequenced by the tivo set original air date.


You can do this by using TWP to append season and epiosode info to the title of each show, in the form of S01E01, S02E02, etc. It doesn't have to be the actual season/episode number, but just in the correct order according to the air date. Then use option 6f to automatically order the episodes, and finally use option 6e to strip off the season/episode info.


----------



## katiebear00

I love the new feature to create folders from scratch!


----------



## rbautch

I posted an updated version of the script with a few new features:

1. Automatically deletes wishlist folders when they are empty. This will reduce clutter when you go to look at your actual wishlists in the Tivo UI. 

2. A few new options to list folders and their contents. I set this up so you can manipulate folders without looking at your TV.


----------



## kenr

As discussed in other threads, DTivos running 6.2a software are affected by series id changes that render the original season passes dead. You need to enter a new season pass to pick up the show with the new series id.

In my case I did this but now the episodes of Kitchen Nightmare I have fall into 2 separate folders, because the series is recorded with 2 separate series ids.

I thought I could use the folders.tcl script posted here to place both episodes in the same folder but upon running it and displaying the list of folders and shows, the script already thinks the shows are in the same folder.

For example:

3464964 Kitchen Nightmares
Revisited: Gordon Returns
Handlebar

Is it possible for folders.tcl to cause both these shows to appear in the same folder in the TiVo GUI even though the script believes they're already in the same folder?


----------



## rbautch

kenr said:


> As discussed in other threads, DTivos running 6.2a software are affected by series id changes that render the original season passes . You need to enter a new season pass to pick up the show with the new series id.
> 
> In my case I did this but now the episodes of Kitchen Nightmare I have fall into 2 separate folders, because the series is recorded with 2 separate series ids.
> 
> I thought I could use the folders.tcl script posted here to place both episodes in the same folder but upon running it and displaying the list of folders and shows, the script already thinks the shows are in the same folder.
> 
> For example:
> 
> 3464964 Kitchen Nightmares
> Revisited: Gordon Returns
> Handlebar
> 
> Is it possible for folders.tcl to cause both these shows to appear in the same folder in the TiVo GUI even though the script believes they're already in the same folder?


That doesn't sound too hard. Ill look into it. In the meantime, you could create a new folder of the same name and transfer shows into it.


----------



## tja273

Just tried this and it worked. Just select "Add show to folder". Enter the folder name. Then use the "show name" only to get ALL episodes added to the folder. The program will combine them on the Tivo GUI in the same folder.

Now, I don't know if this is the "new" folder or the "old" folder. I guess I'll find out when a new episode records next week.


----------



## bnm81002

rbautch said:


> That doesn't sound too hard. Ill look into it. In the meantime, you could create a new folder of the same name and transfer shows into it.


I hope that you can develop a way to combine the 2 folders, it makes it much more easier to do than creating a new folder,


----------



## Conklin

What version should the script be at? When i run it says "Running folders.tcl Version 2.3" i don't get the "2) create new folders" option.


Thanks


----------



## bengalfreak

Conklin said:


> What version should the script be at? When i run it says "Running folders.tcl Version 2.3" i don't get the "2) create new folders" option.
> 
> Thanks


#2 is not create new folders. You are reading the first post in this thread which lists what the script will do. rbautch just happened to put it in a numbered list. That's not the menu of the script.

If you want to create a folder, you simply choose option 1 and type the name of the folder you want to transfer programs to. If the folder doesn't already exist, the script will create it for you.


----------



## bengalfreak

rbautch,

There seems to be an error handling problem with the folders script. When I'm adding shows to a folder, if I mistype a show title, it seems the only way I can get out of the script is to hit a ctrl-c. When i do that, I can't get the script to do anything else until I reboot the Tivo. If I type folders.tcl, I get the menu, but no matter which option I choose, I can't get the script to do anything beyond that.


----------



## chrisshop

How do I load and activate FOLDERS.TCL on my Series 3 Tivo?

18 months after I bought my Series 3, the HDD started to go out. I have successfully installed an internal 1TB drive (WD10EVCS) to replace the defective drive by following the instructions posted at Official eSATA Drive Expansion in 9.2: FAQ + Discussion. It is working great; but now I have the problem of trying to deal with an ever-growing Now Playing List, so I want to organize it using FOLDERS.TCL.

My problem is that I have no idea how to install it. I took a course in GOTRAN in college (_be careful not to drop your tray of punch cards_), and then years later did some simple programming in DOS-BASIC when I bought my first IBM PC 25 years ago, but nothing since. I have read that I can just use ftp or telnet; and while I know what both of those are, I have no idea what I should do with them.

Is it possible for someone of my limited skills to install FOLDERS.TCL? Can anyone post instructions at a level I could understand and follow, or give me a link to such instructions? I dont want to hack very deeply into the Tivo operating system for fear of messing it up. *Am I over my head here?*


----------



## txporter

Are you just trying to put your shows into groups rather than having a long string of recorded shows in your NPL? That can be done by pushing the ENTER button on your tivo remote while in your NPL and turning on grouping.

http://www.tivo.com/mytivo/tipsandtricks/index.html


----------



## rbautch

bengalfreak said:


> rbautch,
> 
> There seems to be an error handling problem with the folders script. When I'm adding shows to a folder, if I mistype a show title, it seems the only way I can get out of the script is to hit a ctrl-c. When i do that, I can't get the script to do anything else until I reboot the Tivo. If I type folders.tcl, I get the menu, but no matter which option I choose, I can't get the script to do anything beyond that.


I don't know what's happening here. Do a ps to see if there's still a folders process trying to complete.


----------



## chrisshop

txporter said:


> Are you just trying to put your shows into groups rather than having a long string of recorded shows in your NPL? That can be done by pushing the ENTER button on your tivo remote while in your NPL and turning on grouping.
> 
> http://www.tivo.com/mytivo/tipsandtricks/index.html


I am already grouping my regular TV shows. My problem is that I am building up an extensive library of movies, and because they all have different names they dont group.


----------



## rbautch

I uploaded a new version to the OP. This one automatically matches up orpan shows to existing folders. I set it up for partial matches on folders, so if a show is called "Star Trek Next Generation" it will automatically get matched up with the "Star Trek" folder. I found this especially useful for tivoserver transfers. If I have a bunch of movies that I want to transfer with tivoserver to a "Movies" folder on the tivo, I can't rename all the files on the PC to the same name, but I can append or prepend -Movies- to the filename so gets matched up with the Movies folder.

This version can also be run from cron, say once every hour, so transferred shows automatically get sucked up into folders. To run from cron every 55 minutes, you might add line to your crontab that looks like this:


Code:


*/55 * * * * /path/to/folders.tcl 7

The script can also be run using selction tools as arguments. For example, running:


Code:


./folders.tcl 4c

 will list all folders and shows, and running:


Code:


./folders.tcl 4

 will go directly to submenu for listing shows. So to automatically match shows with cron, use:


Code:


./folders.tcl 7

or:


Code:


./folders.tcl 8

A few more notes:
- AutoMatching ignores shows that are already in folders. 
- Will work on wishlist folders as well as regular folders. 
- Shows can be AutoMatched with folders based on the show title or the episode name. I may also add a third option to match based on some other obscure or infrequently used MFS object so you can tailor XML files for tivoserver transfers. 
- If you'd rather have exact matches instead of partial matches, edit the script to replace all instances of *$folder* with $folder

Thanks to TCF user Jasch for his idea to add AutoMatching to the script.


----------



## bnm81002

so basically I can combine old shows with new shows using some of the Title's name? with the guide data problems that are existing, this would be a great useful tool to combine the shows, thanks for the great work :up:


----------



## Soapm

rbautch said:


> - Shows can be AutoMatched with folders based on the show title or the episode name. I may also add a third option to match based on some other obscure or infrequently used MFS object so you can tailor XML files for tivoserver transfers.


I would still be appreciative if you could make it sort the shows in a folder by episode number or original air date. Please.....


----------



## HellFish

Doesn't item #8 address your issue? 


> 8) Reorder shows in a folder using season/episode notation. So show.S02E12.mpg appears before show.S03E09.mpg in NPL.


It doesn't sort by original air date, but it does sort shows by episode number.

And thanks for adding folder creation in the last version. It is very useful!


----------



## tomm1079

does this work with tivoHD's

I would love to be able to drop all my movies into a movies folder


----------



## Soapm

HellFish said:


> Doesn't item #8 address your issue?
> 
> It doesn't sort by original air date, but it does sort shows by episode number.
> 
> And thanks for adding folder creation in the last version. It is very useful!


I would have to rename all 200+ MASH episodes with the expected format for the program to work as it is. That would prove very labor intensive having to upload them all to a computer, rename them then put them back on the Tivo.

I was hoping for something that would read the date/episode numbers already coded when they were recorded.


----------



## HellFish

Soapm, you don't have to download every episode to change the title info. As Russ stated in this post, you could rename the episodes via TWP.

If you spent 5 minutes a day, you could do 1 season a day, and it would take 2 weeks to complete. Yes, it's labor intensive, but it's better than waiting for Russ to implement the change that he's not interested in doing.

Russ,
I do have a question about your suggestion in the post I reference above. If I have the shows with torrent formatting (S01E01), use option 6f to sort correctly, option 6e to remove the formatting, use option 6f again, what will happen? Will the shows be kept in the correct Season/Episode order? I can see this happening if I receive new episodes of the series.


----------



## Da Goon

Soapm said:


> I would still be appreciative if you could make it sort the shows in a folder by episode number or original air date. Please.....


I don't know about episode numbers, but if the OriginalAirDate attribute is correct in the recording, then sorting them in this manner is fairly simple. Lightly tested example code :



Code:


#!/tvbin/tivosh
#episode_sort.tcl
set db [dbopen]
ForeachMfsFile fsid name type "/Recording/NowShowingByBucketTitle/" "" {
   RetryTransaction {
      set oad ""
      set recording [db $db openid $fsid]
      set showing [dbobj $recording get Showing]
      set program [dbobj $showing get Program]
      catch {set oad [dbobj $program get OriginalAirDate]}
      if {$oad!=""} {
         dbobj $showing set Date $oad
      }
   }
}

This example code takes every recording and sets its Recorded Date to the same as its OriginalAirDate. It could easily be modified to take a program name as an argument and only change the attributes of that program series. Works for me, as long as OriginalAirDate is correct, anyways.

Some recordings may lack an OriginalAirDate value, and might be sorted incorrectly because of that. Out of a few hundred shows I found about 5 that lacked that information (which can easily be hacked in via tivosh, however). --edit-- Now that I look at it, I think the shows that were missing this attribute were MRV transfers, so perhaps this should work as long as the recordings being changed were made on the same box that you're currently executing the script on.


----------



## Soapm

HellFish said:


> Soapm, you don't have to download every episode to change the title info. As Russ stated in this post, you could rename the episodes via TWP.
> 
> If you spent 5 minutes a day, you could do 1 season a day, and it would take 2 weeks to complete. Yes, it's labor intensive, but it's better than waiting for Russ to implement the change that he's not interested in doing..


I tried that, because I have a 1TB drive with tons of saved movies etc... My NPL takes about 5 minutes to pull up in TWP. Then you have to wait for it to refresh after each edit it was taking a long time then I would loose interest and start other projects. I couldn't do an entire season in 5 minutes. Also, I have complete MASH, all the B&W Andy Griffith, Dragnet, i think you get the point... I'm a junkie for the old shows.


----------



## Soapm

Da Goon said:


> I don't know about episode numbers, but if the OriginalAirDate attribute is correct in the recording, then sorting them in this manner is fairly simple. Lightly tested example code :
> 
> 
> 
> Code:
> 
> 
> #!/tvbin/tivosh
> #episode_sort.tcl
> set db [dbopen]
> ForeachMfsFile fsid name type "/Recording/NowShowingByBucketTitle/" "" {
> RetryTransaction {
> set oad ""
> set recording [db $db openid $fsid]
> set showing [dbobj $recording get Showing]
> set program [dbobj $recording get Program]
> catch {set oad [dbobj $program get OriginalAirDate]}
> if {$oad!=""} {
> dbobj $showing set Date $oad
> }
> }
> }
> 
> This example code takes every recording and sets its Recorded Date to the same as its OriginalAirDate. It could easily be modified to take a program name as an argument and only change the attributes of that program series. Works for me, as long as OriginalAirDate is correct, anyways.
> 
> Some recordings may lack an OriginalAirDate value, and might be sorted incorrectly because of that. Out of a few hundred shows I found about 5 that lacked that information (which can easily be hacked in via tivosh, however). --edit-- Now that I look at it, I think the shows that were missing this attribute were MRV transfers, so perhaps this should work as long as the recordings being changed were made on the same box that you're currently executing the script on.


You're way over my head with this Da Goon... I asume I paste this code in a text file and name it episode_sort.tcl. I would then move it to the Tivo and remove the dos stuff the make it executable.

What is an example of a command line? Will it do an entire folder at once or would I have to do each episode one at a time?


----------



## Da Goon

Soapm said:


> You're way over my head with this Da Goon... I asume I paste this code in a text file and name it episode_sort.tcl. I would then move it to the Tivo and remove the dos stuff the make it executable.
> 
> What is an example of a command line? Will it do an entire folder at once or would I have to do each episode one at a time?


yeah, just paste it into a .tcl file and run it, 'tivosh file.tcl'. The example I posted will run on every show you have on your tivo unless you modify it.


----------



## Soapm

Da Goon said:


> yeah, just paste it into a .tcl file and run it, 'tivosh file.tcl'. The example I posted will run on every show you have on your tivo unless you modify it.


Thanks, this is what I got... Does it look right?



Code:


FamRoom-bash# episode_sort.tcl
invalid attribute: Program
    while executing
"dbobj $recording get Program"
    invoked from within
"set program [dbobj $recording get Program]"
    ("uplevel" body line 5)
    invoked from within
"uplevel $body"
    invoked from within
"transaction {uplevel $body}"
    (procedure "RetryTransaction" line 5)
    invoked from within
"RetryTransaction {
      set oad ""
      set recording [db $db openid $fsid]
      set showing [dbobj $recording get Showing]
      set program [dbob..."
    ("uplevel" body line 2)
    invoked from within
"uplevel $body"
    invoked from within
"ForeachMfsFile fsid name type "/Recording/NowShowingByBucketTitle/" "" {
   RetryTransaction {
      set oad ""
      set recording [db $db openid $fs..."
    (file ".//episode_sort.tcl" line 4)
FamRoom-bash#

Unless I did something wrong, it doesn't appear to have worked because the shows are in the same order.


----------



## Da Goon

Soapm said:


> Thanks, this is what I got... Does it look right?
> 
> 
> 
> Code:
> 
> 
> FamRoom-bash# episode_sort.tcl
> invalid attribute: Program
> while executing
> "dbobj $recording get Program"
> 
> Unless I did something wrong, it doesn't appear to have worked because the shows are in the same order.


you didn't do anything wrong. (note to self:don't post code when you're drunk). The snippet I posted was trying to open the program object directly from $recording instead of from $showing (doh). I fixed it above.


----------



## Soapm

Da Goon said:


> you didn't do anything wrong. (note to self:don't post code when you're drunk). The snippet I posted was trying to open the program object directly from $recording instead of from $showing (doh). I fixed it above.


I think we're closer...



Code:


FamRoom-bash# episode_sort.tcl
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...




Code:


FamRoom-bash# episode_sort.tcl
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_FS_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...


----------



## Da Goon

Soapm said:


> I think we're closer...
> 
> 
> 
> Code:
> 
> 
> FamRoom-bash# episode_sort.tcl
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> 
> 
> 
> 
> Code:
> 
> 
> FamRoom-bash# episode_sort.tcl
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_FS_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...


Were you recording something at the time? Those messages will probably show up if it's trying to manipulate an inprogress recording. Check your NPL, I just sorted 22 episodes of South Park correctly on another box.


----------



## Soapm

Da Goon said:


> Were you recording something at the time? Those messages will probably show up if it's trying to manipulate an inprogress recording. Check your NPL, I just sorted 22 episodes of South Park correctly on another box.


Yes, it was recording.... Good to know...

What command line do you use to sort only one folder like you did with south park?

HHMM.... I stopped the recordings and still got the same thing...

FamRoom-bash# episode_sort.tcl
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_FS_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...


----------



## Da Goon

Soapm said:


> Yes, it was recording.... Good to know...
> 
> What command line do you use to sort only one folder like you did with south park?
> 
> HHMM.... I stopped the recordings and still got the same thing...
> 
> FamRoom-bash# episode_sort.tcl
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_FS_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...


here's a full script modified to take the name of a series as an argument. ie : 'tivosh episode_sort.tcl Futurama' will only sort episodes of Futurama. Even if you got those errors before, it still should have sorted your whole NPL.


----------



## Soapm

Is my command line right for mash? I still get this error.



Code:


FamRoom-bash# [COLOR="Red"]tivosh episode_sort.tcl M*A*S*H[/COLOR]
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...


----------



## Da Goon

Soapm said:


> Is my command line right for mash? I still get this error.
> 
> 
> 
> Code:
> 
> 
> FamRoom-bash# [COLOR="Red"]tivosh episode_sort.tcl M*A*S*H[/COLOR]
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...
> retrying after TV_TM_ACTIVE_LOCK_CONFLICT ...


that's fine. ignore the errors. check your NPL.


----------



## Soapm

Da Goon said:


> that's fine. ignore the errors. check your NPL.


Nope, doesn't seem to work. The dates don't seem to change and they error just keeps going and going and going.

I found a end pad plus thread with that error at DDB and AlphaWolf suggested to put EnableTransactionHoldoff true in the script.

Any thoughts where that would go...
DDB /forum/showthread.php?t=31854&page=11


----------



## Da Goon

just put it at the top under #!/tvbin/tivosh.


----------



## Soapm

Da Goon said:


> just put it at the top under #!/tvbin/tivosh.


The same but no problem, I'm kind of used to the sequence their in and I don't want to hijack Russ thread any more that I did...


----------



## HellFish

Soapm said:


> I tried that, because I have a 1TB drive with tons of saved movies etc... My NPL takes about 5 minutes to pull up in TWP. Then you have to wait for it to refresh after each edit it was taking a long time then I would loose interest and start other projects. I couldn't do an entire season in 5 minutes. Also, I have complete MASH, all the B&W Andy Griffith, Dragnet, i think you get the point... I'm a junkie for the old shows.


Obviously, if you can get Da Goon's script working, that will be much faster. Da Goon, if you can get that script working, I'm sure Soapm isn't the only person that would be interested in using it...

But getting back to using folders.tcl, do you have tabbed browsing available? If so, open the NPL, then open the individual episodes in new tabs. Make your edits and save, then close the tabs. This will eliminate the need to refresh the NPL after each edit... and 5-10 minutes later, you have a complete season done. I've done this in the past, and it works very well.

You can also use this address for accessing the NPL in TWP: *http://192.168.blah.blah/nowshowing?fold=1*
This will speed up the initial NPL load because it groups the shows into folders.

But since you have all those shows you want to do this to, you better pray Da Goon finds da answa (I'm here all week!)


----------



## Soapm

The script worked Hellfish, I was just impatient and was canceling it at first error. It took about 1.5 hours to run but it worked like a charm...

Thanks Da Goon...


----------



## SpacemanSpiff69

I used to run the old folders.tcl without a hitch. When I read about the new features I wanted to try it out. Now when I try to rename a folder I get this error....

can't read "foldertype": no such variable
while executing
"if { $argc == 0 && $foldertype != "theme"} {
if {[file exists /var/spool/cron/crontabs/root]||[file exists /enhancements/varhacks/spool/cron/cron..."
(file "./folders.tcl" line 662)

What am I doing wrong?


----------



## rbautch

SpacemanSpiff69 said:


> I used to run the old folders.tcl without a hitch. When I read about the new features I wanted to try it out. Now when I try to rename a folder I get this error....
> 
> can't read "foldertype": no such variable
> while executing
> "if { $argc == 0 && $foldertype != "theme"} {
> if {[file exists /var/spool/cron/crontabs/root]||[file exists /enhancements/varhacks/spool/cron/cron..."
> (file "./folders.tcl" line 662)
> 
> What am I doing wrong?


Do you actually have folders on the tivo to rename? Are you trying to rename a wishlist folder or regular folder?


----------



## SpacemanSpiff69

rbautch said:


> Do you actually have folders on the tivo to rename? Are you trying to rename a wishlist folder or regular folder?


I do have folders on the Tivo for renaming. The folders do get renamed, but I don't think the cron is updated as the folder names revert back to original with a few days. I am renaming folders created by recording the same show twice for a few minutes.

The old version of folders.tcl worked without a hitch. It has only been since I updated to the new version that the folders don't retain their name.


----------



## rbautch

SpacemanSpiff69 said:


> I do have folders on the Tivo for renaming. The folders do get renamed, but I don't think the cron is updated as the folder names revert back to original with a few days. I am renaming folders created by recording the same show twice for a few minutes.
> 
> The old version of folders.tcl worked without a hitch. It has only been since I updated to the new version that the folders don't retain their name.


Check your crontab to see if there's a line in there to rename the folders. If so, copy it to bash to see if it works. Are you still getting the error you posted above? If so, this will prevent the script from altering your crontab to automatically rename folders. I can't seem to reproduce the error.


----------



## rbautch

Also check to see if line 975 of the script reads: set foldertype "default"


----------



## SpacemanSpiff69

rbautch said:


> Check your crontab to see if there's a line in there to rename the folders. If so, copy it to bash to see if it works. Are you still getting the error you posted above? If so, this will prevent the script from altering your crontab to automatically rename folders. I can't seem to reproduce the error.


I don't know what happened between using the older version and the new one but now the contents of /var/spool/cron/crontabs/root is:
0 4 * * * fakecall.tcl

Does anyone have an 'old version' link so I can see if it still works? Silly me overwrote it with the new version and I can't find my backup



rbautch said:


> Also check to see if line 975 of the script reads: set foldertype "default"


line 975 says: puts "episode is $episode_number"


----------



## rbautch

Looks like you're running version 2.3. Download the current version (2.5) from the OP and try again. Also see the release notes for version 2.4.


----------



## SpacemanSpiff69

rbautch said:


> Looks like you're running version 2.3. Download the current version (2.5) from the OP and try again. Also see the release notes for version 2.4.


HA .. Ha ... ha ha..... ooops!  Helps when you use the right version!
I d/l from the 'other' site but never checked the version. Thanks for the help. 2.5 works like a charm.


----------



## x60hz

Hey you guys are like geniuses to me. I've been looking for a way to rename my Tivo folders forever now and it looks like Rbautch, you can do it with your folders.tcl. Can you guys maybe give me some help on running this script. I'm an ok VB guy but know nothing about tcl coding. How would I run this code to communicate with the Tivo DVR and what is the syntax? Thanks!!!


----------



## rbautch

x60hz said:


> Hey you guys are like geniuses to me. I've been looking for a way to rename my Tivo folders forever now and it looks like Rbautch, you can do it with your folders.tcl. Can you guys maybe give me some help on running this script. I'm an ok VB guy but know nothing about tcl coding. How would I run this code to communicate with the Tivo DVR and what is the syntax? Thanks!!!


It's a "tivosh" script, which is Tivo's customized version of TCL. Type the following at bash:


Code:


tivosh folders.tcl


----------



## rbautch

I just posted version 2.7 to the OP. This one is particularly useful for tivoserver or mfs_ftp transfers by automatically duplicating your PC's folders on your tivo. So, if you have a directory on your PC with folders called "Movies" or "Musical Performances", any shows inside those folders that get transferred will automatically get put in folders of the same name or your tivo. If the folders don't exist, they'll get created.

To use this feature, you must create a text file called folders.txt in the same directory as folders.tcl. This text file should contain the shows and folders you want them to get sucked into, separated by a slash (a sample is attached to this post). When you select option 9, folders.tcl reads the text file to figure out what shows go in which folders. This text file would be cumbersome to create for your entire tivosever directory, so I wrote a script called list.sh to automatically generate the folders.txt file when you run it from your tivoserver directory. It's written for a Linux tivoserver box, but it will also work with Cygwin on a Windows machine. I'm sure a dos batch file could also be written to do the same.

After you get the text file created for your tivoserver directory, create a cron job to periodically run folders.tcl and AutoMatch the tivoserver shows to folders. Something like this in your crontab should do the trick:


Code:


*/30 * * * *	/enhancements/folders.tcl 9

I know this is a little round about, but once you get it set up, it works unattended. You can also edit folders.txt to customize the way you match shows with folders. For example, you might want all episodes of CSI, CSI New York, and CSI Miami to automatically get sucked up into a single "CSI" folder.

edit 4/21/10: I updated the list.sh script to handle multiword folder names.


----------



## whitepelican

Here's a quick question for you, rbautch: Is there any way to combine the contents of two folders that have the same name? It seems that for some reason many of my MRV transfers end up creating two different folders with the same series name but with different episodes in each. None of these episodes are seen as "orphans", so I can't do anything to automatically associate them with the correct folder. The only thing I've been able to do so far is to remove each episode one at a time from one folder and then automagically re-assign them to the other once they are seen as orphans. But that takes a helluva long time to accomplish. Is there any easier way?


----------



## rbautch

whitepelican said:


> Here's a quick question for you, rbautch: Is there any way to combine the contents of two folders that have the same name? It seems that for some reason many of my MRV transfers end up creating two different folders with the same series name but with different episodes in each. None of these episodes are seen as "orphans", so I can't do anything to automatically associate them with the correct folder. The only thing I've been able to do so far is to remove each episode one at a time from one folder and then automagically re-assign them to the other once they are seen as orphans. But that takes a helluva long time to accomplish. Is there any easier way?


I checked this out a few months ago when the guide data changed, but it wasn't a trivial addition to the folders script so I abandoned it. Here's a roundabout way that may save you some time though:

- Run the folders script and choose options 6a or 6b to change the title or episode title of all the shows in the folder you want to remove shows from.
- Pick a title or episode title that has some unique word or characters, but also contains the name of the new folder where you want the shows to reside. So if all shows are called Seinfeld, you might rename them all to "Seinfeld-new". 
- Run the folders script again to remove the shows from the folder in one fell swoop by entering the unique word or character as your search term - remember this feature will do partial matches. (search for "-new" on the previous example). 
- Run the script again to use the AutoMatch feature to put the shows in the new folder.


----------



## whitepelican

Thanks for the workaround method, I'll give it a shot.

Edit: Seemed to work just fine. Thanks again, rbautch.


----------



## whitepelican

Another question on using folders.tcl:

I'm trying to figure out how to correctly name tmf files on my PC so that they automatically end up where I want on my DirecTivos. I'm using MovieLoader/mfs_ftp to transfer the files. What I have are a bunch of old kid's movies that I've ripped from DVD/VHS, and I want them all to end up in a folder entitled "Kid Movies" which already exists on the Tivo. I'm running crond to occasionally do a "folders.tcl 6" and then "folders.tcl 7". 

So, for example, I have the movie "Peter Pan", and I want it to automatically end up with the right series/episode titles and be placed inside the folder "Kid Movies". I've tried a few things, such as mfs_ftp naming convention, and just using "Kid Movies - Peter Pan.tmf" and I either end up with no episode title at all or the superfluous "Kid Movies -" as part of the episode title. So what format of filenames should I use on my computer to accomplish what I want? Help me, rbautch, you're my only hope!


----------



## unclemoosh

Have you tried looking at/renaming the title with TWP? If you at least look at it maybe that would help you out on the PC-side. Maybe?


----------



## whitepelican

unclemoosh said:


> Have you tried looking at/renaming the title with TWP? If you at least look at it maybe that would help you out on the PC-side. Maybe?


Well, sure. I end up fixing up my mistakes by using TWP each time. But I'd like to have it a little more automated, especially because I have four different DirecTivos that can pull these movies off my PC, and I don't want to keep having to use TWP to rename them everytime.


----------



## rbautch

whitepelican said:


> Another question on using folders.tcl:
> 
> I'm trying to figure out how to correctly name tmf files on my PC so that they automatically end up where I want on my DirecTivos. I'm using MovieLoader/mfs_ftp to transfer the files. What I have are a bunch of old kid's movies that I've ripped from DVD/VHS, and I want them all to end up in a folder entitled "Kid Movies" which already exists on the Tivo. I'm running crond to occasionally do a "folders.tcl 6" and then "folders.tcl 7".
> 
> So, for example, I have the movie "Peter Pan", and I want it to automatically end up with the right series/episode titles and be placed inside the folder "Kid Movies". I've tried a few things, such as mfs_ftp naming convention, and just using "Kid Movies - Peter Pan.tmf" and I either end up with no episode title at all or the superfluous "Kid Movies -" as part of the episode title. So what format of filenames should I use on my computer to accomplish what I want? Help me, rbautch, you're my only hope!


You don't need to modify the titles at all. You just need to create a text file called folders.txt that lists all the shows and folders you want them to get sucked up into when you transfer them. Then use folders.tcl 9 to make it happen. It's is further explained in post #106 above.


----------



## whitepelican

rbautch said:


> You don't need to modify the titles at all. You just need to create a text file called folders.txt that lists all the shows and folders you want them to get sucked up into when you transfer them. Then use folders.tcl 9 to make it happen. It's is further explained in post #106 above.


I don't think that would work very well for me, either, as I'm constantly adding new shows. If I understand that option correctly, it would mean I need to modify the folders.txt file on all four Tivos every time I wanted to add one new show. I was hoping there was a way I could do it by simply using the proper filename and then doing the "auto add orphans" & "nice" names options in crond.


----------



## Soapm

whitepelican said:


> I don't think that would work very well for me, either, as I'm constantly adding new shows. If I understand that option correctly, it would mean I need to modify the folders.txt file on all four Tivos every time I wanted to add one new show. I was hoping there was a way I could do it by simply using the proper filename and then doing the "auto add orphans" & "nice" names options in crond.


Can't you make a master copy of the TXT file and just paste to each Tivo? That shouldn't be much work.


----------



## rbautch

whitepelican said:


> I don't think that would work very well for me, either, as I'm constantly adding new shows. If I understand that option correctly, it would mean I need to modify the folders.txt file on all four Tivos every time I wanted to add one new show. I was hoping there was a way I could do it by simply using the proper filename and then doing the "auto add orphans" & "nice" names options in crond.


Okay now I get it. Rename the files like this: "Peter PanS01E01.Kids Movies" then run AutoMatch and then run make nice. It will strip off everything to the right of and including S01E01, change the title to Kids Movies, and change the Episode Title to Peter Pan. Make sure you AutoMatch first. Not sure how it will handle spaces in the title and folder name. Let me know.


----------



## whitepelican

rbautch said:


> Rename the files like this: "Peter PanS01E01.Kids Movies" then run AutoMatch and then run make nice. It will strip off everything to the right of and including S01E01, change the title to Kids Movies, and change the Episode Title to Peter Pan. Make sure you AutoMatch first. Not sure how it will handle spaces in the title and folder name. Let me know.


That almost worked. I'm assuming the spaces are the problem, correct? Any other ideas of what I might try? Thanks.



Code:


AutoMatching orphan show "CinderellaS01E01.Kid Movies.tmf" to folder "Kid Movies
"
Searching for Kid Movies........................................................
................................................................................
.............................................................Found a folder name
d "Kid Movies" containing 7 episodes.
FAILED TO ADD SHOW TO "Kid Movies" FOLDER! MAKE SURE THE SHOW NAME AND EPISODE N
AME DO NOT CONTAIN SQUARE BRACES.
AutoMatch complete!


----------



## snake98

rbautch said:


> I just posted version 2.7 to the OP. This one is particularly useful for tivoserver or mfs_ftp transfers by automatically duplicating your PC's folders on your tivo. So, if you have a directory on your PC with folders called "Movies" or "Musical Performances", any shows inside those folders that get transferred will automatically get put in folders of the same name or your tivo. If the folders don't exist, they'll get created.


your folders.zip doesn't contain a tcl file.


----------



## HellFish

The tcl file is in the 1st post.


----------



## bengalfreak

rbautch,

It might be a good idea to modify this script to look for the return key as a response and error out of that. For instance, if you accidentally hit "return" instead of typing a show name when copying shows to a folder you have created, the script will copy every show on your Tivo to that folder, its a mess and alot of work to correct. This is the second time I've done this. I'm not *****ing because i appreciate all of the great work you've done, but an improvement to this script might be in order.


----------



## rbautch

bengalfreak said:


> rbautch,
> 
> It might be a good idea to modify this script to look for the return key as a response and error out of that. For instance, if you accidentally hit "return" instead of typing a show name when copying shows to a folder you have created, the script will copy every show on your Tivo to that folder, its a mess and alot of work to correct. This is the second time I've done this. I'm not *****ing because i appreciate all of the great work you've done, but an improvement to this script might be in order.


I just uploaded version 2.9 to the OP, which incorporates the feature described above. I set it so when you enter a show name, it has to be greater than 1 character long. You can also modify the minimum number of characters to suit your liking (variable is called "minshowname"). A few other enhancements in this version include:

- Fix miscounting number of episodes in a folder.

- Add verbose mode for options 7,8, and 9 so it doesn't appear frozen during lengthy process.

- Updated list.sh script here.

- Added code to prevent duplicate folder listings on THDs - by jkozee.

- Added option 5g: Reorder based on OriginalAirDate (set Showing->Date to OriginalAirDate) [Useful when collecting old episodes of a series not airing in order] - by jkozee.

- Added option 5h: Reorder based on StartDate (set Showing->Date to StartDate) [Undo for 5g] - by jkozee.


----------



## StanSimmons

rbautch said:


> - Added option 5g: Reorder based on OriginalAirDate (set Showing->Date to OriginalAirDate) [Useful when collecting old episodes of a series not airing in order] - by jkozee.


I just tried v2.9 on a DTiVo running v6.2, option 5g did not appear to do anything on a folder of Perry Mason episodes dating from the late 50's to early 60's.

I ran folders.tcl from the command line as seen here:


Code:


bash-2.02# folders.tcl
Running folders.tcl Version 2.9
Please select from the following:
1   Add show(s) to a folder.
2   Change the name of a folder.
3   Remove a show from a folder.
4   List folders and shows.
5   Change the attributes of all shows in a folder.
6   Make episode titles in all folders "nice".
7   AutoMatch orphaned shows to folders - by title.
8   Automatch orphaned shows to folders - by epidose title.
9   AutoMatch orphaned shows - custom match using folders.txt.
Enter the number corresponding to the action you want to perform: 5
Now select which attribute you want to change:
 a   Change the Title
 b   Change the Episode Description
 c   Change the Original Air Date
 d   Change the Actors
 e   Make show titles and episode titles "nice"
 f   Reorder episodes based on season/episode information in show title
 g   Reorder based on OriginalAirDate (set Showing->Date to OriginalAirDate)
 h   Reorder based on StartDate (set Showing->Date to StartDate)
 Now enter a letter from this subtask menu: g

 Enter the name of the folder containing the shows you want to modify
 : Perry Mason

Searching for Perry Mason.......................................................
................................................................................
..............................................
Found a wishlist folder named "Perry Mason"
All showing->dates match OriginalAirDate in the "Perry Mason" folder.
bash-2.02#

Below are some screen shots of TWP of examples.

















Did I do something wrong, or did the old show dates confuse folders.tcl?


----------



## rbautch

Stan, that part of the script was added by jkozee, who only had TivoHD's to test on. I'm guessing that one of the MFS varables are stored differently on that Tivo. I'll do some testing on my 6.2 Dtivos. What kind of Tivo did you run it on?


----------



## StanSimmons

rbautch said:


> Stan, that part of the script was added by jkozee, who only had TivoHD's to test on. I'm guessing that one of the MFS varables are stored differently on that Tivo. I'll do some testing on my 6.2 Dtivos. What kind of Tivo did you run it on?


An HDVR2 running 6.2-01-2-151.


----------

