Page 1 of 1
Rename File, Create Folder In Current Location, Put Newly Renamed File In New Folder
Posted: 27 Feb 2018, 23:41
by SoonerLater
An example is given on this site that to (1) rename a movie file, (2) create a folder of the same name in the same location and (3) move the newly renamed file to the new folder, use this code:
../{movie}/{movie}
If I have a file
\\server\share\folder\Final.Portrait.2017.1080p.NF.WEBRip.DDP.5.1.H264-CMRG.mkv
and then I drag it into Filebot (GUI, of course), then I run the above preset, Filebot (1) properly renames the file and (2) creates a folder of the same name and (3) puts the new file in the new folder. However, the new folder is
one level up in the file tree from where I ran the command. So instead of ending up with:
\\server\share\folder\Final Portrait (2017)\Final Portrait (2017).mkv
which is what I want, I end up with
\\server\share\Final Portrait (2017)\Final Portrait (2017).mkv
which is not what I want.
How should I change my code to achieve the desired result?
OS: Windows 10 Pro 64 bit
Filebot: Microsoft Store purchased, but version unknown - there's no "help, about" for me to check the program version and it doesn't show up in Control Panel \ Programs.
Re: Rename File, Create Folder In Current Location, Put Newly Renamed File In New Folder
Posted: 28 Feb 2018, 03:14
by rednoah
You have:
You want:
Because you want to create the folder in the current folder, and not the parent folder.
.. refers to the parent folder of the file being processed, while
. refers to the current folder of the file being processed.
TIP: If you specify exactly what you want in your format, then you will get exactly what you want.
Code: Select all
\\server\share\folder\{movie}\{movie}
TIP 2: I recommend using
{plex} or
{plex.tail} instead of
{movie}/{movie} because that'll take care of various corner cases and special cases you may not think of until you run into certain problems.
Re: Rename File, Create Folder In Current Location, Put Newly Renamed File In New Folder
Posted: 22 Nov 2023, 20:18
by lemon389
Hello rednoah,
I would like to request your support for a scenario similar like this.
I'm renaming a Series that is in this path:
Code: Select all
C:\Tool\A\Output\Series Name\Season\Video_name.mkv
I want this output:
Code: Select all
C:\Tool\A\Output\New Series Name\New Season\New Video_name.mkv
All the path before the Series Name changes depending on the input video.
if i use:
Groovy: Select all
../{n.upperInitial().lowerTrail()....}
Then, the output is:
Code: Select all
C:\Tool\A\Output\Series Name\New Series Name\New Season\New Video_name.mkv
I tried with one more dot to go one level above like this:
Groovy: Select all
.../{n.upperInitial().lowerTrail()....}
But, I received this error:
Question:
What should be the correct sintax?
Thanks!
Re: Rename File, Create Folder In Current Location, Put Newly Renamed File In New Folder
Posted: 22 Nov 2023, 20:23
by lemon389
Update:
I tried leaving it without "../" and now it works:
But earlier today, when I had the statements like that, it was moving the files as follows, directly into the drive root folder.
Re: Rename File, Create Folder In Current Location, Put Newly Renamed File In New Folder
Posted: 23 Nov 2023, 08:14
by rednoah
. refers to the current directory.
.. refers to the parent directory. You can do
../../.. to refer to the parent of the parent of the parent and so on. See
What are "." and ".." in a directory? for details.

What is the real path of
C:\Tool\A\Output? This is likely a made up path for illustration purposes. However, if you were to use
{plex} on this example path it would likely work because
Output /
Complete /
Downloads /
etc have special
"structure root folder" meaning to FileBot, and so FileBot would be inclined to reorganize files within the common structure root if the format is relative.

That said, in this case I would probably go with
"take the first 4 folder levels from the original file path" logic:
Re: Rename File, Create Folder In Current Location, Put Newly Renamed File In New Folder
Posted: 23 Nov 2023, 15:54
by lemon389
Hello rednoah,
C:\Tool\A\Output is for illustration, but, I have different folder names, A might be changed with another name, also, Output might be changed depending on the source.
What I understood so far, is that, Filebot takes the path of the video files, and, from that point, the parent directories starts to count.
Example:
If I use ..//, then, the files are moved to parent directory of the video files, in this case in the Season XX folder.
I will try your suggestions, thanks a lot for your support!
Re: Rename File, Create Folder In Current Location, Put Newly Renamed File In New Folder
Posted: 24 Nov 2023, 02:39
by rednoah

What is the real path of
C:\Tool\A\Output though?
(NOTE: behaviour may depend on the real file path)
lemon389 wrote: ↑23 Nov 2023, 15:54
What I understood so far, is that, Filebot takes the path of the video files, and, from that point, the parent directories starts to count.
If you use
../{plex} or
{folder}/{plex} or
../../{plex} or
{folder.dir}/{plex} and so on as format, then yes.
If you use
{plex}, then maybe, depending on the current file structure and folder names. In the example above,
C:\ is likely considered structure root, since
Tools is not a known structure root folder.