Changes

Jump to navigation Jump to search
51 bytes added ,  14:45, 23 October 2007
Updated rename to do full rename, not just extension append.
Line 81: Line 81:  
</blockquote>
 
</blockquote>
   −
8. '''Replace file extension of all files within a directory'''
+
8. '''Replace file extension of all files within a directory tree'''
 
  <blockquote>
 
  <blockquote>
<tt>find ~/MyDirectory -name '*.txt' -exec mv {} {}.xls \;</tt><br><br>
+
<tt>find ~/MyDirectory -name '*.txt' -exec bash -c 'mv "{}" "`dirname "{}"`/`basename "{}" txt`xls"'  \;</tt><br><br>
    
The first arg is the parent directory of the data. Find will recurse thru all sub-dirs. This command replaces ".txt" with ".xls"
 
The first arg is the parent directory of the data. Find will recurse thru all sub-dirs. This command replaces ".txt" with ".xls"

Navigation menu