#1 2015-01-26 21:24

eswiig
Member
Registered: 2015-01-26
Posts: 6

Use only the first word of a folder

Purchased a Pro License.

Is there a way to only use the first word of a folder instead of the entire folder name (if it's more than 1 word)
? If not, could there be in the future?

Example:

I have a folder named "Pictures - Volume 001"

If I use :File_FolderName: then the output will be

"Pictures - Volume 001" but I want it to only fetch the first word of the folder, so it becomes "Pictures" instead.

a space would indicate that the word ended.

and no, I can't simply insert "Pictures" as the folder name may vary and I want to avoid having to modify the text based on the folder name hmm

Last edited by eswiig (2015-01-26 21:33)

Offline

#2 2015-01-26 22:22

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,482

Re: Use only the first word of a folder

You can remove not needed parts after you insert the full folder name.

For example:
1) Insert: Insert "[:File_FolderName:] " as Prefix
2) Rearrange: Split by exact pattern of delimiters "[", " ", "]", New pattern "$1$2$4"

Input: C:\Temp\Pictures - Volume 001\File.txt
Output: C:\Temp\Pictures - Volume 001\Pictures File.txt

What this does is inserts the folder name in square brackets, and then extracts only the first word out of the square brackets. Note that if there won't be a space in the folder name then the square brackets will be left as is, so you may need to also strip them with another rule.

Last edited by den4b (2015-01-26 22:25)

Offline

#3 2015-01-26 22:37

eswiig
Member
Registered: 2015-01-26
Posts: 6

Re: Use only the first word of a folder

Thank you for the reply!

It is awesome that there is such a function but...

Hmmm what am I doing wrong?

this is the path: C:\Temp\Pictures - Volume 001\File.txt

renamer.jpg

Last edited by eswiig (2015-01-26 22:52)

Offline

#4 2015-01-26 22:56

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,482

Re: Use only the first word of a folder

There might be a non-standard space character involved (one of unicode variants).

Can you try using RegEx rule instead:
1) Insert: Insert "[:File_FolderName:] " as Prefix
2) RegEx: Replace expression "\[(.*?)\s(.*?)\]" with "$1"

If it still doesn't work, please use "Export all columns to clipboard" option from the "Export" menu and paste the content here as code (use the button in the toolbar when writing a post).

Offline

#5 2015-01-26 23:01

eswiig
Member
Registered: 2015-01-26
Posts: 6

Re: Use only the first word of a folder

almost there,

the RexEx gave me "PicturesFile.txt"

can you please adjust it to give me just "Pictures"?

Offline

#6 2015-01-26 23:03

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,482

Re: Use only the first word of a folder

Simply insert the extra space in your first rule.

Note the space character at the end of "[:File_FolderName:] ".

Offline

#7 2015-01-26 23:04

eswiig
Member
Registered: 2015-01-26
Posts: 6

Re: Use only the first word of a folder

Sorry to be a bother, I am totally green when it comes to RegEx...
I must say support is excellent... and I will continue to support by keeping/renewing the Pro License.

that gave me "Pictures File.txt"

I simply want only "Pictures.txt"

Last edited by eswiig (2015-01-26 23:05)

Offline

#8 2015-01-26 23:06

eswiig
Member
Registered: 2015-01-26
Posts: 6

Re: Use only the first word of a folder

File.txt	Pictures File.txt	OK

Offline

#9 2015-01-26 23:07

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,482

Re: Use only the first word of a folder

No problem, just add a Delete rule as your first rule:
1) Delete: Delete from Position 1 until the End
2) Insert: Insert "[:File_FolderName:]" as Prefix
3) RegEx: Replace expression "\[(.*?)\s(.*?)\]" with "$1"

Offline

#10 2015-01-26 23:07

eswiig
Member
Registered: 2015-01-26
Posts: 6

Re: Use only the first word of a folder

that did it, excellent..

thanks, consider this issue solved...

Last edited by eswiig (2015-01-26 23:08)

Offline

Board footer

Powered by FluxBB