Move files into alphabetically named folders

Come up with a useful post-processing script? Share it here!
Faintuk
Newbie
Newbie
Posts: 25
Joined: March 18th, 2012, 9:18 am

Move files into alphabetically named folders

Post by Faintuk »

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
User avatar
sander
Release Testers
Release Testers
Posts: 9061
Joined: January 22nd, 2008, 2:22 pm

Re: Move files into alphabetically named folders

Post by sander »

And what about

"(1234/1231) Supermovie 2"

"12-04-2011 Theme"

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

Oh, which OS?
Faintuk
Newbie
Newbie
Posts: 25
Joined: March 18th, 2012, 9:18 am

Re: Move files into alphabetically named folders

Post by Faintuk »

Im using windows

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

Cheers
User avatar
sander
Release Testers
Release Testers
Posts: 9061
Joined: January 22nd, 2008, 2:22 pm

Re: Move files into alphabetically named folders

Post by sander »

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.
Faintuk
Newbie
Newbie
Posts: 25
Joined: March 18th, 2012, 9:18 am

Re: Move files into alphabetically named folders

Post by Faintuk »

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
NoTolerance
Full Member
Full Member
Posts: 127
Joined: June 27th, 2012, 9:55 am

Re: Move files into alphabetically named folders

Post by NoTolerance »

This would be fairly simple to do. Still something you're after?
Faintuk
Newbie
Newbie
Posts: 25
Joined: March 18th, 2012, 9:18 am

Re: Move files into alphabetically named folders

Post by Faintuk »

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

Thanks
NoTolerance
Full Member
Full Member
Posts: 127
Joined: June 27th, 2012, 9:55 am

Re: Move files into alphabetically named folders

Post by NoTolerance »

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

The Most Awesome Movie Ever Made
Most Awesome Movie Ever Made, The
NoTolerance
Full Member
Full Member
Posts: 127
Joined: June 27th, 2012, 9:55 am

Re: Move files into alphabetically named folders

Post by NoTolerance »

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\"
friet
Newbie
Newbie
Posts: 3
Joined: September 21st, 2012, 3:52 pm

Re: Move files into alphabetically named folders

Post by friet »

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.
NoTolerance
Full Member
Full Member
Posts: 127
Joined: June 27th, 2012, 9:55 am

Re: Move files into alphabetically named folders

Post by NoTolerance »

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
friet
Newbie
Newbie
Posts: 3
Joined: September 21st, 2012, 3:52 pm

Re: Move files into alphabetically named folders

Post by friet »

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\
NoTolerance
Full Member
Full Member
Posts: 127
Joined: June 27th, 2012, 9:55 am

Re: Move files into alphabetically named folders

Post by NoTolerance »

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.
friet
Newbie
Newbie
Posts: 3
Joined: September 21st, 2012, 3:52 pm

Re: Move files into alphabetically named folders

Post by friet »

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.
NoTolerance
Full Member
Full Member
Posts: 127
Joined: June 27th, 2012, 9:55 am

Re: Move files into alphabetically named folders

Post by NoTolerance »

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.
Post Reply