How can I batch rename all files in a folder to '.txt'?

1

1

Can I change all files in my folder (extensions like .log01012010, .log02012010) to .txt? So I can search through all the files with the built-in Windows 7 file searcher?

user101579

Posted 2012-06-05T13:39:13.267

Reputation: 123

Keep a backup before trying any of the suggestions if the files are anything of value. – Daniel Andersson – 2012-06-05T13:49:34.957

I want to search inside the files. – user101579 – 2012-06-05T14:05:06.687

You have asked a XY question I have answered your real question (X) for you but you I recommend editing your original question to something like "How do I search for text in files that do not end in .txt?"

– Scott Chamberlain – 2012-06-05T20:50:19.137

Answers

4

If you want absolutely every file within a given folder changed to a txt extension, you can open a command window in that folder and type ren *.* *.txt and it will change them all to .txt files, overwriting their original extensions. If you need to maintain the extensions (like if several have the same filename but different extensions) you can enter the command as ren *.* *.*.txt which will append the .txt extension to the end of the current extension.

techturtle

Posted 2012-06-05T13:39:13.267

Reputation: 8 059

2The latter might be better of you have several files with the same basename "foo.c foo.h" – RedGrittyBrick – 2012-06-05T14:03:30.620

1

Those log files appear to have a date stamp in them. If you change them to a txt extension, you will loose that date stamp. Also, if whatever creates the log file has the same file name, the date stamp may be the only distinguishing feature. This could possibly overwrite some of the files if they are named identically.

If all you are trying to do is search, the Windows 7 search feature will find partial words. So if you want to find just the "log" files, simply navigate to that folder and enter *.log in the search box. It will return anything with log in the extension.

CharlieRB

Posted 2012-06-05T13:39:13.267

Reputation: 21 303

1

A much better solution is just use a tool that can search for text inside of files other than txt. I use Agent Ransack. It is free for both personal and commercial use and works great.

Scott Chamberlain

Posted 2012-06-05T13:39:13.267

Reputation: 28 923