Move files into alphabetically named folders

Come up with a useful post-processing script? Share it here!

Move files into alphabetically named folders

Postby Faintuk » April 25th, 2012, 6:21 pm

Just wondering if it's possible to have a script move film files to a specific folder based on the alphabet?

Eg Scream 4 would get moved to e:\movies\s\
Avatar would get moved to e:\movies\a\

Cheers
Faintuk
Newbie
Newbie
 
Posts: 22
Joined: March 18th, 2012, 10:18 am

Re: Move files into alphabetically named folders

Postby sander » April 25th, 2012, 6:55 pm

And what about

"(1234/1231) Supermovie 2"

"12-04-2011 Theme"

... where should these movie files go ... ?

Oh, which OS?
User avatar
sander
Release Testers
Release Testers
 
Posts: 3502
Joined: January 22nd, 2008, 3:22 pm

Re: Move files into alphabetically named folders

Postby Faintuk » April 25th, 2012, 7:23 pm

Im using windows

And I guess movies with numbers in could go into a folder called 0-9

Cheers
Faintuk
Newbie
Newbie
 
Posts: 22
Joined: March 18th, 2012, 10:18 am

Re: Move files into alphabetically named folders

Postby sander » April 26th, 2012, 1:58 am

Ah, Windows. Sorry, I have Linux.

Proof of Concept on Linux:

Code: Select all
echo '[[389/2323]] Nice Movie' |  tr -c -d 'a-zA-Z0-9' | awk '{ print toupper(substr($1,1,1)) }'


will return "3", so that's good.

Explanation:
the 'echo' prints an example NZB name. In the script, it should be $2
the 'tr' removes strange characters only leaving letters and numbers.
the 'awk' takes the first letter, and turns it to upper case

As Windows has no tr and awk, you cannot run this on Windows.
User avatar
sander
Release Testers
Release Testers
 
Posts: 3502
Joined: January 22nd, 2008, 3:22 pm

Re: Move files into alphabetically named folders

Postby Faintuk » April 26th, 2012, 6:07 pm

i found this website that gives a script that will do what im after just wondering if anyone could modify this to run in sab

http://www.roysac.com/blog/2009/03/file ... anization/

cheers
Faintuk
Newbie
Newbie
 
Posts: 22
Joined: March 18th, 2012, 10:18 am

Re: Move files into alphabetically named folders

Postby NoTolerance » July 4th, 2012, 12:52 pm

This would be fairly simple to do. Still something you're after?
NoTolerance
Jr. Member
Jr. Member
 
Posts: 53
Joined: June 27th, 2012, 10:55 am

Re: Move files into alphabetically named folders

Postby Faintuk » July 4th, 2012, 1:06 pm

Yes this is still something I'd want to get working

Thanks
Faintuk
Newbie
Newbie
 
Posts: 22
Joined: March 18th, 2012, 10:18 am

Re: Move files into alphabetically named folders

Postby NoTolerance » July 4th, 2012, 2:35 pm

How do you want to handle folders that start with "The"?

The Most Awesome Movie Ever Made
Most Awesome Movie Ever Made, The
NoTolerance
Jr. Member
Jr. Member
 
Posts: 53
Joined: June 27th, 2012, 10:55 am

Re: Move files into alphabetically named folders

Postby NoTolerance » July 4th, 2012, 4:08 pm

I just set it up both ways, giving you the option, since I had to include an INI file anyway.

Give this a try.

Put the AlphaSort.exe and AlphaSort.ini into your sab scripts folder. Edit the AlphaSort.ini file. Be sure to put quotes around the path name and use a trailing backslash: "E:\Movies\"
NoTolerance
Jr. Member
Jr. Member
 
Posts: 53
Joined: June 27th, 2012, 10:55 am

Re: Move files into alphabetically named folders

Postby friet » September 21st, 2012, 4:55 pm

Tried it but it doesn't work. Put this in the Post-Processing Scripts Folder and edited the ini file but nothing happens. (And yes, I have tried turning it off and on again.)

edit: Now I'm getting this:
Exit(1) You need to specify your final destination directory in the INI file.
friet
Newbie
Newbie
 
Posts: 3
Joined: September 21st, 2012, 4:52 pm

Re: Move files into alphabetically named folders

Postby NoTolerance » September 21st, 2012, 8:54 pm

I have to ask the obvious: Did you specify a final destination directory in the INI file?

Can you expand the log (click More) and paste what it says? It might be useful if you post a copy of your completed INI file, too.

Or you can email me this info: NoTolerance <at> gmail <dot> com
NoTolerance
Jr. Member
Jr. Member
 
Posts: 53
Joined: June 27th, 2012, 10:55 am

Re: Move files into alphabetically named folders

Postby friet » September 24th, 2012, 3:53 pm

The log:

Code: Select all
Making sure NZB was processed successfully...
Sab NZB processing completed without error. Preparing to process...
You need to specify your final destination directory in the INI file.


My ini file:

Code: Select all
[Paths]
;===========================================================================
; Full Path to Final Destination Directory - Use Trailing Backslash
; Example: "D:\Movies\"
;===========================================================================
FinalDir="G:\Downloads\Complete\"

[Renaming]
;===========================================================================
; Move 'The' to end of folder name. 0 = NO, 1 = YES
; Example: The Greatest Movie Ever
; 0 = D:\Movies\T\The Greatest Movie Ever
; 1 = D:\Movies\G\Greatest Movie Ever, The
;===========================================================================
RenameThe=0


In the sabnzbd config I have the same destination folder: G:\Downloads\Complete\
friet
Newbie
Newbie
 
Posts: 3
Joined: September 21st, 2012, 4:52 pm

Re: Move files into alphabetically named folders

Postby NoTolerance » September 27th, 2012, 3:59 pm

What is the path to your INI file? It looks for it in the \scripts folder (e.g. C:\Program Files\sabnzbd\scripts\AlphaSort.ini) by default.

In Sab, under Config - Folders, what do you have listed for the Post-Processing Scripts Folder?

Based on the error, it's not able to read the INI file. The only reason this should happen is if the INI file and the EXE aren't in the same directory.

This isn't currently causing you an issue (because it's not getting that far), but you *may* have an issue with your final destination directory being the same as your completed download directory. I didn't really test it that way when I whipped it together.
NoTolerance
Jr. Member
Jr. Member
 
Posts: 53
Joined: June 27th, 2012, 10:55 am

Re: Move files into alphabetically named folders

Postby friet » September 28th, 2012, 4:26 pm

Thanks for the help but unfortunately it still doesn't work. I changed the destination folder in the ini file to a new folder (so no longer my completed folder). The scripts folder is correct in the config and the exe and ini are in the same folder.

This is what I have in config - categories:

Image

It picks up the script, so that folder must be correct.
friet
Newbie
Newbie
 
Posts: 3
Joined: September 21st, 2012, 4:52 pm

Re: Move files into alphabetically named folders

Postby NoTolerance » October 1st, 2012, 10:44 am

friet wrote:Thanks for the help but unfortunately it still doesn't work. I changed the destination folder in the ini file to a new folder (so no longer my completed folder). The scripts folder is correct in the config and the exe and ini are in the same folder.

This is what I have in config - categories:

Image

It picks up the script, so that folder must be correct.


I think I know what I did wrong. I'm working on a fix and will have it posted shortly.
NoTolerance
Jr. Member
Jr. Member
 
Posts: 53
Joined: June 27th, 2012, 10:55 am

Next

Return to Post-Processing Scripts