Script you have help me with before.

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
MickeMM
Posts: 44
Joined: 03 Apr 2019, 10:52

Script you have help me with before.

Post by MickeMM »

In my MovieFormat.groovy i have this code that you have help me with before.
Everything works but i have a little problem.

Today its sunday and filebot makes week 5, but here in Sweden its stil week 4. New week every monday.

I have try to google some java code and try to change yyyy to YYYY and ww to WW but nothing helps what i can see.

Code: Select all

{ 'omkodat/film' + today.format('/yyyy/ww') }
Any idea how to fix this?
User avatar
rednoah
The Source
Posts: 23000
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script you have help me with before.

Post by rednoah »

That'll be quite a bit more complicated, but this should work:

Format: Select all

{
	new java.text.SimpleDateFormat("yyyy/ww", Locale.GERMANY).format(today.toLocalDate().toDate())
}




EDIT:

FileBot r10180 adds additional API for this kind of use case:

Format: Select all

{
	today.format("yyyy/ww", Locale.GERMANY)
}
:idea: Please read the FAQ and How to Request Help.
MickeMM
Posts: 44
Joined: 03 Apr 2019, 10:52

Re: Script you have help me with before.

Post by MickeMM »

Thank you so much.
Do u know why its not working with SWEDEN as country but GERMANY work?

Thanks again! <3
User avatar
rednoah
The Source
Posts: 23000
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Script you have help me with before.

Post by rednoah »

SWEDEN does not have a static constant in the Locale class:
https://docs.oracle.com/en/java/javase/ ... ld-summary


You can use new Locale("sv","SE") instead of Locale.GERMANY though. Both locales use "week starts on Monday" so either will work for your use case.
:idea: Please read the FAQ and How to Request Help.
MickeMM
Posts: 44
Joined: 03 Apr 2019, 10:52

Re: Script you have help me with before.

Post by MickeMM »

Thanks for the link and explanation, i appreciate it.
Post Reply