Page 1 of 1
Set destination drive while renaming
Posted: 24 Aug 2016, 10:00
by suppi3838
Hi,
Could anyone help me out in setting how to dynamically set the destination path while renaming?
i.e. Suppose if the external HDD is connected, then i want to move the renamed files into Hdd else keep it in same drive where source file resides.
Basically want to specify if-else condition for -- format or --output attribute.
Re: Set destination drive while renaming
Posted: 24 Aug 2016, 16:21
by rednoah
1.
--output format is fixed and must be a folder, so you'd have to set it via your own shell script depending on the situation. If you're using bash this might be ok, but if you're on Windows CMD scripting is not sensible.
2.
The
--format is scriptable, so you can do anything, including checks for existing paths. I'd use the format if I wanted full control of the output path.
The existing examples should get you a long way here:
viewtopic.php?f=5&t=2
The example that sorts files into the drive with the most disk space should probably work out of the box for this use case.
Re: Set destination drive while renaming
Posted: 25 Aug 2016, 03:38
by suppi3838
Hi..Thanks for the shared info.
As I'm new to command line, i'm having trouble with below script. Could you please help in modifying the script to work with based on drive letter availability instead of disk space.i.e. If 'D' exists set it as "D:/" or if 'E' exists set is as "E:/"...
{['C:', 'D:', 'E:'].collect{ (it+'/TV/'+n) as File }.sort{ a, b -> a.exists() <=> b.exists() ?: a.diskSpace <=> b.diskSpace }.last()}/{episode}
Re: Set destination drive while renaming
Posted: 25 Aug 2016, 04:13
by rednoah
Use the GUI and play with the Format Editor.
A format like this might be easier to understand and modify:
Code: Select all
{('X:' as File).exists() ? 'X' : 'Y'}:/Media/...
Re: Set destination drive while renaming
Posted: 25 Aug 2016, 06:47
by suppi3838
Thanks a lot..That works for me

Re: Set destination drive while renaming
Posted: 19 Dec 2016, 20:38
by immenz
Hi, is there a way to pass a regex as file(folder) name?
For example, i want to check, if "Showname/Season 02 .*" exists.
Re: Set destination drive while renaming
Posted: 20 Dec 2016, 01:17
by rednoah
Yes, Groovy supports if-then-else-conditions and regular expressions.
What exactly are you trying to do? What have you tried?
Re: Set destination drive while renaming
Posted: 08 Jan 2017, 18:31
by immenz
I have the following folder structure: ../series/Season xx [source]-[language]-[group]/episode
if there is a new episode, i want to check if a folder for that season and language already exist, regardless the source and group information. If so, move the file to this folder, if not, create the folder with the given tags.
Besides this, i also struggle with some other problems, so i haven't a final expression yet, only some fragments. Problem is, that detection of source, language and group are quite long, and i don't want to repeat it in the whole expression.
This is my current messy state:
Code: Select all
{[['/volume1/Serien/', 'S:/'].collect{ it + primaryTitle as File}.sort{a,b -> a.exists() <=> b.exists()}.last()].collect().sort{a,b -> a.getFolders({it.toString().find(s.pad(2) + /.*/+{audio.size()>1?'DL':(file.path.find(/\W[Gg][Ee][Rr]/)? 'DE' :'EN')}+/.*/)}) <=> 'Staffel ' + {s.pad(2)} + {allOf{file.path.lower().match(/(Amazon(HD)?|netflix(uhd)?)/)}{model.source.minus(null).unique().max()}{audio.size()>1?'DL':(file.path.find(/\W[Gg][Ee][Rr]/)? 'DE' :'EN')}{model.group.minus(null).countBy {it}.groupBy {it.value}.max{it.key}.value.keySet().join('')}.join('-').upper()}}.last()}
with audio:
Code: Select all
{audio.size()>1?'DL':(file.path.find(/\W[Gg][Ee][Rr]/)? 'DE' : 'EN')]
source
Code: Select all
{{file.path.lower().match(/(Amazon(HD)?|netflix(uhd)?)/)}{model.source.minus(null).unique().max()}
and group
Code: Select all
{model.group.minus(null).countBy {it}.groupBy {it.value}.max{it.key}.value.keySet().join('')}.join('-').upper()}}.last()
it tried several functions like find, match etc, but couldn't get them to work properly.
Re: Set destination drive while renaming
Posted: 08 Jan 2017, 18:52
by rednoah
Nobody will be able to understand your intent based on that. I recommend keeping things as simple as possible.
Re: Set destination drive while renaming
Posted: 08 Jan 2017, 19:10
by immenz
Sorry, i just want to find out if a folder "season xx .?-language-.?" already exist. If so, move the file there, if not, create it and move it there.
If possible, without double checking the language.
Re: Set destination drive while renaming
Posted: 08 Jan 2017, 20:07
by rednoah
I don't quite understand why you would need to check in advance, if the files is going to be moved to the same folder in either case anyway.
I recommend using a simple format that yields the same path regardless of whether or not some other file or folder exists.
Re: Set destination drive while renaming
Posted: 08 Jan 2017, 20:54
by immenz
The Use Case is a TV Show, that comes in once a week or other period. In some Case, the episode is released by another group, and therefore there would be another folder based on the release group. Another case is a show, which is released in 2 languages with only a few days between them. I want to separate them by language, otherwise i could not determine which language the file has, because the episode names from lookup are already in my selected language (german)
Re: Set destination drive while renaming
Posted: 09 Jan 2017, 06:37
by rednoah
I would do something like this:
Code: Select all
X:/Media/TV Shows/{n}/Season {s} {audioLanguages}/{n} - {s00e00} - {t} {[group]}
{audioLanguages} may not work for older files where that information is not available in the container. If that is a problem then
{any{fn.match(/GER/)}{'ENG'}} might be a reasonable solution.