Renaming all files with no extension to .txt

A swapping-ground for Regular Expression syntax

Renaming all files with no extension to .txt

Postby v1nce » Thu Sep 01, 2011 1:50 am

(I hope I am in the right section, apologies if not)

I am trying to use BRU to rename all files in selected folders that do not have a file extension to a .txt file extension and was wondering how to accomplish this exactly. I'm guessing I have to use regular expressions but don't know how or what code to use. Again, apologies if I made typical n00b mistake. (Well, I'm not a BRU n00b but never had to do this part before - in that I am a n00b). :mrgreen:
v1nce
 
Posts: 2
Joined: Thu Sep 01, 2011 1:43 am

Re: Renaming all files with no extension to .txt

Postby sinnistar99 » Sat Sep 03, 2011 4:52 am

Hey I was struggling with this for awhile and still don't have a BRU solution but it can easily be done in a cmd prompt using

rename *. *.txt
sinnistar99
 
Posts: 1
Joined: Sat Sep 03, 2011 3:04 am

Re: Renaming all files with no extension to .txt

Postby v1nce » Tue Sep 06, 2011 3:36 am

Now if only that did all files in sub directories I'd be set! Thanks though for that one!!
v1nce
 
Posts: 2
Joined: Thu Sep 01, 2011 1:43 am

Re: Renaming all files with no extension to .txt

Postby bitmonger » Fri Oct 07, 2011 7:28 am

Try the following in the Regex field 1
Match: ^([^.]+)$
This means match only filenames which don't contain an extension period.
The outer parentheses mean capture those that match this criteria.

Replace: \1.txt
The \1 is the captured filename followed by the period and the extension txt
Make sure the Include Ext box is checked!

Also, make sure Selections (12) field is a single asterisk *

In the samples I tried, it added the .txt extension only to the files having none.

If you want to include files in subdirectories, then check the box beside Subfolders in the Selections (12) field.

Good luck
bitmonger
 
Posts: 50
Joined: Sat Sep 22, 2007 5:05 am


Return to Regular Expressions