Return to Snippet

Revision: 42747
at March 10, 2011 03:04 by alassiter


Initial Code
## Use find to search for the files I want recursively from the current path
## Powerful utility, man find to read the man pages

find . -name "*.rhtml"   # List all files that end in .rhtml
find . -type f           # Find all regular files 


## I can use wc (word count) with the -l flag to count the number of returned lines

find . -name "*.rhtml" | wc -l    # Count the number of files that match


## I can then add a while and mv command to rename the files

find . -name "*.rhtml" | while read f; do mv ./"$f" "${f%rhtml}html.erb"; done

Initial URL

                                

Initial Description
A couple of snippets useful for file management. I use these to make sure I understand how many files I'm about to modify, and then rename them.

Initial Title
Rename files from command line

Initial Tags
command, unix, linux, line

Initial Language
Bash