Get name of parent folder of parent folder of file

Support for Windows users
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Get name of parent folder of parent folder of file

Post by RBCC »

Image
I am trying to figure out the steps involved in doing what is show in the picture , could someone write a tutorial? John
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [Noob] How do I do this?

Post by rednoah »

Based on what I told you last time, you should know this already:

Code: Select all

f.dir.dir.name
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

How about f[2]?
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

Sure, but counting path elements from the left is probably not a good idea if you ever add an additional folder level.
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

I used file.dir.dir.name and got new directories created. How do i put the file in the same folder it came from? John
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

Your format should create a path like this "Avatar.avi" and not a path like this "/path/with/slashes/Avatar.avi" which will be resolved relative to wherever the file happens to be.
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

But they are all in seperate folder.
Say you have john,fred and sue in the folder c:\macgyver\seattle. And you want to use macgyver , episode 6. To put the renamed file into. But it makes a dir under the root for each file for each file. Is there anyway to put all them back into the dir they came from??? John
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

If you want FileBot to move your files to C:/A/B.c then you just need to write a format that evaluates to C:/A/B.c that's all.
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

I dont want them to be moved!
Just use the folder name that they are in as part of the name.
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

1. A filename:

Code: Select all

filename.ext
2. A relative path:

Code: Select all

file/name.ext
Presumably, your format is generating paths and not filenames. The difference betweens paths and filenames is that paths contain slashes while filename don't contain slashes.
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

Image
will f.dir.dir.name create a new folder? if so, how do I do this so it wont..
the folder that it is in is: M:\Diagnosis Murder\Season 7. John
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

What is the value of f.dir.dir.name?
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

Season 6
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

The String "Season 6" will definitely not cause the creation of any folders.
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

So will f.dir.dir.dir.name?
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

That depends on the value. If the value doesn't contain / or \ then no.

Look at the result:

If it's an absolute path it'll move files exactly as is:

Code: Select all

C:/a/b/c.mp4
If it's a relative path it'll move files relatively to where they are:

Code: Select all

b/c.mp4
If it's a file name, it'll rename files relatively to where they are:

Code: Select all

c.mp4
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

Image
How do I put the renamed file back into its original directory? DOes f.name. dir do this?
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

The format does not do anything. The format produces a file path, and then files will be move/renamed according to that file path.

What is the file path that your format produces? How is that file path not what you want it to be?
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

Y:/perry mason/1x19.mp4, John
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

The format produces absolute paths . such as

Code: Select all

c:/diagnosis murder/season 1/ diagnosis:murder 1x3.mp4
how to create a format call to use relative paths?

Code: Select all

/diagnosis:murder/season 1/diagnosis:murder 1x3.mp4
Or the filename.ext ie:

Code: Select all

diagnosis:murder 1x3.mp4
? If it uses absolute paths!
John
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get name of parent folder of parent folder of file

Post by rednoah »

1.
If you want this path:

Code: Select all

diagnosis:murder 1x3.mp4
Then make your format expression only produce this path.


2.
Paths like this will work as expected:

Code: Select all

./diagnosis:murder 1x3.mp4

Code: Select all

../diagnosis:murder 1x3.mp4
If you don't know what . or .. means you will need to learn some basics first. ;)
:idea: Please read the FAQ and How to Request Help.
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

I know that

Code: Select all

..
goes up one directory and

Code: Select all

 ..\.. 
goes up 2 , when I am in the editor of filebot do I put those in where the filename is such as

Code: Select all

../../diagnosis:murder 1x4.mp4
? Am I understanding you right? But if just want the season number

Code: Select all

..\..\[color=#0080FF]diagnosis:murder [/color]1x14.mp4
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

Would it be easier to use Y:/Diagnosis Murder/season 1/Diagnosis Murder 1x3.mp4 [Airdate] f.dir.dir.name episode title? so it will copy it to that location?

Before I was trying to use the ../.. in the format string! John
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

Please show code that shows how to copy the file to the right directory and use the new directory name for season #. So that it will be put into the right directory. Ok? John
RBCC
Posts: 118
Joined: 17 May 2016, 02:23

Re: Get name of parent folder of parent folder of file

Post by RBCC »

Image
How do I copy a file into another directory and then using the new directory name use a part of that directory name and put it into the new folder for the file? Like in the picture! John
Post Reply