Friday, July 27, 2012

How to search file contents in Windows7

M$, realizing that the built-in file search utility didn't quite work right anyhow when searching file contents in XP, has now made the same utility impossible to use in Windows 7. Thank goodness we will no longer be tempted to try to use it any more. Google searches on the problem so far have yielded no answers except for ridiculously cryptic answers provided by M$ staff. So far, there is no clue in the following links:

http://answers.microsoft.com/en-us/windows/forum/windows_7-files/in-windows-7-i-want-to-search-for-all-files/aadfe1f1-4a33-406b-8e72-bb920efa4f30
http://answers.microsoft.com/en-us/windows/forum/windows_7-files/search-file-contents-in-windows-7/44920b75-ff71-4683-96eb-04055d090273

The short answer is install Cygwin, or in my case I was able to use the "Find in files" option in TextPad to do what I needed

Sunday, July 8, 2012

Renaming large groups of files with find

My normal inclination is to use xargs coupled with find to do something batch-y like renaming groups of files across a whole directory tree, but I've had a lot of trouble getting the syntax perfect for using something like cp with xargs. It turns out that the find at the start of the chain has a -exec argument that allows multiple uses of the found file name no fuss no muss like xargs should. The command is:

find . -name "*.htm" -exec cp -p {} {}.original \;

The key seems to be in the \; at the end, which I guess that I wasn't doing right before.

Here the site that had the info that got me this breakthrough; it's in somebody's comments near the bottom:

http://csm.mech.utah.edu/content/2011/03/01/use-of-the-shell-xargs-command/