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"