Rename file based on text in the file

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Rename file based on text in the file

Postby Rudolf » Wed Jan 22, 2014 3:51 pm

Hi

I need to sort out 800 000 archived email files and would like to do it by email address.

The files are .msg and are text based, in the files is a line "X-MDRcpt-To: xxxxxxxxx@xxxxxxxx.xxx"

Final file name to be "xxxxxxxxx@xxxxxxxx.xxx - (Original file name).msg

Can this be done? and please give some direction as to how?

Great program so by the way.
Rudolf
 
Posts: 3
Joined: Wed Jan 22, 2014 3:37 pm

Re: Rename file based on text in the file

Postby Rudolf » Fri Jan 24, 2014 9:18 am

Is this a silly question or a difficult one ?
Rudolf
 
Posts: 3
Joined: Wed Jan 22, 2014 3:37 pm

Rename file based on its text-content

Postby truth » Fri Jan 24, 2014 11:11 am

BRU wont read a file's content, seeking rename criteria.
'Exceptions' are file-attributes & exif-values (slowing performance if not needed).

Sed is well-suited for this, but most seem to prefer graphical apps.
Without sed, I'd probably resort to something like:
For /f "delims=: tokens=1,3" %F in ('findstr /r /c:"^X-MDRcpt-To: .*@" *.msg') do REN "%F" "%G - (%~nF)%~xF"

Sed is a LOT faster/cleaner: quits file-reading once text is found (if desired), spaces no concern, etc.
Sorry, I've no experience using graphical apps for this, hopefully someone will have a recommendation.

Apps that file-read like this should let users configure how far into each file should be read (before giving up)
and set what action(s) should be taken after a 1st-occurence is found.
Last edited by truth on Fri Jan 24, 2014 11:50 pm, edited 1 time in total.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Rename file based on text in the file

Postby Rudolf » Fri Jan 24, 2014 2:39 pm

Thanks for the tip.

Appreciate the your effort!

Will check it out.
Rudolf
 
Posts: 3
Joined: Wed Jan 22, 2014 3:37 pm

Re: Rename file based on text in the file

Postby Stefan » Fri Jan 24, 2014 9:18 pm

Or try out ReNamer

http://www.den4b.com/wiki/ReNamer:Pascal_Script:Read_file_content



.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to BRU Support