1 (edited by ypikhar 2016-08-20 07:01:07)

Topic: [SOLVED] how to rename by the text content



I tried this one ,but it is not my wish.
I wish to rename by the file content  automatically ,

e.g. apple is the first line in file 1

orange is the first line of file 2.

how to directly rename by their own content, e.g. file 1 rename to apple
file 2 rename to orange.etc

I want it to automatically rename ,do not need any filename into the expression like this : %T{"file 1"}
,I tried %T1,but not successful!

As I have a lot of files has the first or second line to rename. it is not possible to manually input filename of each of them.

question 2:

if there a way to search through each file content ,to rename filename with any text before gold inside the text of each files.

e.g. apple gold in file 1
orange gold in file 2

could it add to the future wish list

Thanks in advance.

Re: [SOLVED] how to rename by the text content

Hello and welcome to this forum,

1) To extract lines from the treated file you can use : %T{%f} or %T{%fc} (depending on the complexity of the renaming expression).
This is rapidly explained in the help : Expression/Advanced features/Variables as parameters.

2) Here is what I understand : the first line of each file contains text which may include the word "gold". You want only the text before it.
You can achieve with the following expression : %T1{%f}(s/ *\ygold\y.*$//)
Here is how it works :
%T1{%f} will extract the first line of the currently treated file
(s/ *\ygold\y.*$//) is a regular expression modifier that will remove the text starting by the "gold" word (golden won't make it)

I hope this will help you. Do not hesitate to ask for more explanation.

Sorry for my late reply.

Re: [SOLVED] how to rename by the text content

thank you

very handy! smile