Bash Rename File Extensions - Revision history http://wiki.ljackson.us/index.php?title=Bash_Rename_File_Extensions&action=history Revision history for this page on the wiki en MediaWiki 1.7.1 Fri, 29 Mar 2024 12:33:15 GMT Ljackson: /* Syntax */ http://wiki.ljackson.us/index.php?title=Bash_Rename_File_Extensions&diff=3501&oldid=prev <p><span class="autocomment">Syntax</span></p> <table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;"> <tr> <td colspan='2' width='50%' align='center' style="background-color: white;">←Older revision</td> <td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 21:37, 28 October 2018</td> </tr> <tr><td colspan="2" align="left"><strong>Line 25:</strong></td> <td colspan="2" align="left"><strong>Line 25:</strong></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.&lt;EXISTING_EXT&gt;; do mv $i ${i%%.&lt;EXISTING_EXT&gt;}.&lt;RESULTING_EXT&gt;; done</td><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.&lt;EXISTING_EXT&gt;; do mv $i ${i%%.&lt;EXISTING_EXT&gt;}.&lt;RESULTING_EXT&gt;; done</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td>-</td><td style="background: #ffa; font-size: smaller;">Another <span style="color: red; font-weight: bold;">example</span></td><td>+</td><td style="background: #cfc; font-size: smaller;">Another <span style="color: red; font-weight: bold;">examples</span></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.JPG; do j=`echo $i | cut -d . -f 1`; j=$j&quot;_from_mark.jpg&quot;; echo $j; mv $i $j; done;</td><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.JPG; do j=`echo $i | cut -d . -f 1`; j=$j&quot;_from_mark.jpg&quot;; echo $j; mv $i $j; done;</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"> for i in *.py; do cp &quot;$i&quot; &quot;${i%-*}.py&quot;; done</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"> for i in *.py; do mv &quot;$i&quot; &quot;${i%.py}-json.py&quot;; done</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">String Operations</td><td> </td><td style="background: #eee; font-size: smaller;">String Operations</td></tr> </table> Sun, 28 Oct 2018 21:37:10 GMT Ljackson http://wiki.ljackson.us/Talk:Bash_Rename_File_Extensions Ljackson: /* Syntax */ http://wiki.ljackson.us/index.php?title=Bash_Rename_File_Extensions&diff=3458&oldid=prev <p><span class="autocomment">Syntax</span></p> <table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;"> <tr> <td colspan='2' width='50%' align='center' style="background-color: white;">←Older revision</td> <td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 02:47, 29 November 2016</td> </tr> <tr><td colspan="2" align="left"><strong>Line 18:</strong></td> <td colspan="2" align="left"><strong>Line 18:</strong></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.JPG; do mv $i ${i%%.JPG}.jpg; done</td><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.JPG; do mv $i ${i%%.JPG}.jpg; done</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"> for f in *.jpg; do mv &quot;$f&quot; &quot;${f%.jpg}&quot;; done</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">If you would like to use this function for other types of files here is a basic template:</td><td> </td><td style="background: #eee; font-size: smaller;">If you would like to use this function for other types of files here is a basic template:</td></tr> <tr><td colspan="2" align="left"><strong>Line 32:</strong></td> <td colspan="2" align="left"><strong>Line 34:</strong></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"> printf &quot;%s\n&quot; img{00{1..9},0{10..99},{100..999}}.png</td><td> </td><td style="background: #eee; font-size: smaller;"> printf &quot;%s\n&quot; img{00{1..9},0{10..99},{100..999}}.png</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;">Basic Example (Files without File Extensions)</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"> for f in *; do mv &quot;$f&quot; &quot;$f.jpg&quot;; done</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Mac OS X]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Mac OS X]]</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Linux]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Linux]]</td></tr> </table> Tue, 29 Nov 2016 02:47:24 GMT Ljackson http://wiki.ljackson.us/Talk:Bash_Rename_File_Extensions Ljackson: /* Syntax */ http://wiki.ljackson.us/index.php?title=Bash_Rename_File_Extensions&diff=3382&oldid=prev <p><span class="autocomment">Syntax</span></p> <table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;"> <tr> <td colspan='2' width='50%' align='center' style="background-color: white;">←Older revision</td> <td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 07:25, 31 December 2014</td> </tr> <tr><td colspan="2" align="left"><strong>Line 30:</strong></td> <td colspan="2" align="left"><strong>Line 30:</strong></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"> for i in *; do mv $i ${i#1440.jpg.*}.jpg; done</td><td> </td><td style="background: #eee; font-size: smaller;"> for i in *; do mv $i ${i#1440.jpg.*}.jpg; done</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"> printf &quot;%s\n&quot; img{00{1..9},0{10..99},{100..999}}.png</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Mac OS X]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Mac OS X]]</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Linux]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Linux]]</td></tr> </table> Wed, 31 Dec 2014 07:25:23 GMT Ljackson http://wiki.ljackson.us/Talk:Bash_Rename_File_Extensions Ljackson: /* Syntax */ http://wiki.ljackson.us/index.php?title=Bash_Rename_File_Extensions&diff=3375&oldid=prev <p><span class="autocomment">Syntax</span></p> <table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;"> <tr> <td colspan='2' width='50%' align='center' style="background-color: white;">←Older revision</td> <td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 07:11, 31 December 2014</td> </tr> <tr><td colspan="2" align="left"><strong>Line 26:</strong></td> <td colspan="2" align="left"><strong>Line 26:</strong></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.JPG; do j=`echo $i | cut -d . -f 1`; j=$j&quot;_from_mark.jpg&quot;; echo $j; mv $i $j; done;</td><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.JPG; do j=`echo $i | cut -d . -f 1`; j=$j&quot;_from_mark.jpg&quot;; echo $j; mv $i $j; done;</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;">String Operations</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"> for i in *; do mv $i ${i#1440.jpg.*}.jpg; done</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Mac OS X]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Mac OS X]]</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Linux]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Linux]]</td></tr> </table> Wed, 31 Dec 2014 07:11:42 GMT Ljackson http://wiki.ljackson.us/Talk:Bash_Rename_File_Extensions Ljackson at 19:47, 26 October 2008 http://wiki.ljackson.us/index.php?title=Bash_Rename_File_Extensions&diff=3088&oldid=prev <p></p> <table border='0' width='98%' cellpadding='0' cellspacing='4' style="background-color: white;"> <tr> <td colspan='2' width='50%' align='center' style="background-color: white;">←Older revision</td> <td colspan='2' width='50%' align='center' style="background-color: white;">Revision as of 19:47, 26 October 2008</td> </tr> <tr><td colspan="2" align="left"><strong>Line 22:</strong></td> <td colspan="2" align="left"><strong>Line 22:</strong></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.&lt;EXISTING_EXT&gt;; do mv $i ${i%%.&lt;EXISTING_EXT&gt;}.&lt;RESULTING_EXT&gt;; done</td><td> </td><td style="background: #eee; font-size: smaller;"> for i in *.&lt;EXISTING_EXT&gt;; do mv $i ${i%%.&lt;EXISTING_EXT&gt;}.&lt;RESULTING_EXT&gt;; done</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;">Another example</td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"></td></tr> <tr><td colspan="2">&nbsp;</td><td>+</td><td style="background: #cfc; font-size: smaller;"> for i in *.JPG; do j=`echo $i | cut -d . -f 1`; j=$j&quot;_from_mark.jpg&quot;; echo $j; mv $i $j; done;</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;"></td><td> </td><td style="background: #eee; font-size: smaller;"></td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Mac OS X]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Mac OS X]]</td></tr> <tr><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Linux]]</td><td> </td><td style="background: #eee; font-size: smaller;">[[Category:Linux]]</td></tr> </table> Sun, 26 Oct 2008 19:47:46 GMT Ljackson http://wiki.ljackson.us/Talk:Bash_Rename_File_Extensions Ljackson at 01:16, 4 November 2006 http://wiki.ljackson.us/index.php?title=Bash_Rename_File_Extensions&diff=1683&oldid=prev <p></p> <p><b>New page</b></p><div>== Summary ==<br /> <br /> This is a simple function to quickly rename many files using Bash. It can be very useful for renaming pictures, mp3s, and movies.<br /> <br /> == Supported Operating Systems ==<br /> <br /> * Mac OS X and Terminal<br /> * Unix<br /> * Linux<br /> <br /> == Requirements ==<br /> <br /> * Bash<br /> <br /> == Syntax ==<br /> <br /> Below is a simple example for renaming uppercase jpg files to lowercase:<br /> <br /> for i in *.JPG; do mv $i ${i%%.JPG}.jpg; done<br /> <br /> If you would like to use this function for other types of files here is a basic template:<br /> <br /> for i in *.&lt;EXISTING_EXT&gt;; do mv $i ${i%%.&lt;EXISTING_EXT&gt;}.&lt;RESULTING_EXT&gt;; done<br /> <br /> [[Category:Mac OS X]]<br /> [[Category:Linux]]</div> Sat, 04 Nov 2006 01:16:46 GMT Ljackson http://wiki.ljackson.us/Talk:Bash_Rename_File_Extensions