Can I rename a file to the contents of the first line?

General discussions about Advanced Find and Replace
Post Reply
digitalmonkeyman
Posts: 4
Joined: Sun Sep 16, 2007 7:35 am

Can I rename a file to the contents of the first line?

Post by digitalmonkeyman »

The text of the first line is what I would like to rename the file to.

Is this program capable of that?

Thank You

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Re: Can I rename a file to the contents of the first line?

Post by Abacre »

Yes. It's possible with Advanced Find and Replace.

For example you have the file with the following text in it:

Code: Select all

hello.txt
hello world
this is the test
the end of file
Go to main menu - Action - Options - Batch Replace
check "Include File Name Into Search Scope"
check "Rename File Name if it was changed"
check "Modifier S"

Go to Batch replace tab, check on "Use regular expressions".
Put into the grid, search for:
.*\r\n(.*)\r\n

Replace with:
$1\r\n$1\r\n

That's all I verified it works perfectly.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Post Reply