{"id":65501,"date":"2025-05-05T03:01:00","date_gmt":"2025-05-04T17:01:00","guid":{"rendered":"https:\/\/www.rjmprogramming.com.au\/ITblog\/?p=65501"},"modified":"2025-05-04T18:54:42","modified_gmt":"2025-05-04T08:54:42","slug":"renaming-to-aid-with-numerical-file-sorts-almalinux-command-line-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/renaming-to-aid-with-numerical-file-sorts-almalinux-command-line-tutorial\/","title":{"rendered":"Renaming to Aid with Numerical File Sorts AlmaLinux Command Line Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Renaming to Aid with Numerical File Sorts AlmaLinux Command Line Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_for_almalinux.gif\" title=\"Renaming to Aid with Numerical File Sorts AlmaLinux Command Line Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Renaming to Aid with Numerical File Sorts AlmaLinux Command Line Tutorial<\/p><\/div>\n<p>We wanted to revisit the <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php\" rel=\"noopener\">File Renaming Web Application<\/a> of <a title='Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial' href='#ranfsclct'>Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial<\/a> to see if there are any &#8220;moving from&#8221; &#8230;<\/p>\n<ul>\n<li>CentOS Apache PHP version starting with a 5 \u2026 to \u2026<\/li>\n<li>AlmaLinux Apache PHP version starting with an 8<\/li>\n<\/ul>\n<p> &#8230; issues with the PHP.  A mute point, though, as we were reminded during our testing, because we made this web application inactive, probably quite wisely, on our live rjmprogramming.com.au version, so the testing was more that we didn&#8217;t stuff up the still actively working &#8220;download to a local Apache\/PHP\/MySql web server such as <a target=\"_blank\" title='MAMP' href='http:\/\/www.mamp.info' rel=\"noopener\">MAMP<\/a>&#8221; mode of use.  <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_for_almalinux.gif\" rel=\"noopener\">Spoiler alert &#8230; no muck up!<\/a>  So, what did we learn?  Trivial, but &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n if ($argv) {<br \/>\n    \/\/ do a command line usage set of commands ...<br \/>\n<br \/> <br \/>\n    \/\/ ... until here<br \/>\n }<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p> &#8230; is <font color=blue>better expressed as<\/font> &#8230;<\/p>\n<p>&lt;?php<br \/>\n<code><br \/>\n if (<font color=blue>isset(<\/font>)$argv<font color=blue>)<\/font>) {<br \/>\n    \/\/ do a command line usage set of commands ...<br \/>\n<br \/> <br \/>\n    \/\/ ... until here<br \/>\n }<br \/>\n<\/code><br \/>\n?&gt;<\/p>\n<p> &#8230; to avoid errors in <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php---GETME\" rel=\"noopener\">a tweaked<\/a> <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php---GETME\" rel=\"noopener\">rename_to_aid_sorting.php<\/a> we recommend for use on a local Apache\/PHP\/MySql web server such as <a target=\"_blank\" title='MAMP' href='http:\/\/www.mamp.info' rel=\"noopener\">MAMP<\/a>, as mentioned above.<\/p>\n<p><!--p>You can also see this play out at WordPress 4.1.1's <a target=\"_blank\" href='\/\/www.rjmprogramming.com.au\/ITblog\/renaming-to-aid-with-numerical-file-sorts-almalinux-command-line-tutorial\/' rel=\"noopener\">Renaming to Aid with Numerical File Sorts AlmaLinux Command Line Tutorial<\/a>.<\/p-->\n<hr>\n<p id='ranfsclct'>Previous relevant <a target=\"_blank\" title='Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/renaming-to-aid-with-numerical-file-sorts-command-line-and-curl-tutorial\/' rel=\"noopener\">Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting_actions_curl.jpg\" title=\"Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial<\/p><\/div>\n<p>Yesterday&#8217;s <a title='Renaming to Aid with Numerical File Sorts Actions Tutorial' href='#ranfsat'>Renaming to Aid with Numerical File Sorts Actions Tutorial<\/a> had good interaction characteristics, in our books (<font size=3>&#8230; but as of this news bulletin, not in our pamphlettes <\/font><font size=2>and we hope to resume normal transmission forthwith <\/font><font size=1>like &#8230;<\/font>) <a style=\"text-decoration:underline;cursor:pointer;\" onclick='alert(\"You say mesa but I say but ... because cannot bring myself to say butte, thank you very much.\");'>but<\/a>, out of PHP&#8217;s three modes of use (which we talked about at <a target=\"_blank\" title='CSH\/KSH\/PHP Numerical Bubble Sort Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/cshkshphp-numerical-bubble-sort-tutorial\/' rel=\"noopener\">CSH\/KSH\/PHP Numerical Bubble Sort Tutorial<\/a>) &#8230;<\/p>\n<ul>\n<li>Surfing the Net &#8230; is very interactive and we can use HTML form elements for navigation purposes &#8230; for example, URL (on  local <a target=\"_blank\" title='MAMP Mac Apache\/PHP\/MySql local web server' href='http:\/\/www.mamp.info\/' rel=\"noopener\">MAMP<\/a> (Mac) Apache\/PHP\/MySql web server) &#8230; <i>http:\/\/localhost:8888\/rename_to_aid_sorting.php?dirone=.%2F&amp;dirtwo=Django_Python-&amp;asteriskybit=%5B0123456789%5D*.*<\/i> &#8230; but more than likely the environment where users will think to use this PHP application is via &#8230;<\/li>\n<li>Command Line Usage &#8230; for example, be in MAMP&#8217;s \/Applications\/MAMP\/htdocs\/ directory with &#8230; <i>php rename_to_aid_sorting.php .\/Django_Python-<\/i> # or &#8230;<\/li>\n<li><a target=\"_blank\" href='http:\/\/en.wikipedia.org\/wiki\/CURL' title='Curl information from Wikipedia ... thanks' rel=\"noopener\">Curl<\/a> Usage &#8230; for example, be in MAMP&#8217;s \/Applications\/MAMP\/htdocs\/ directory with &#8230; <i>curl http:\/\/localhost:8888\/rename_to_aid_sorting.php?inspec=.\/Django_Python-<\/i> # you can see in action below &#8230;<\/li>\n<\/ul>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/MvWzTFdWMBQ\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/p>\n<p>Up near the top of the code processing input parameters the PHP code differentiation goes &#8230;<\/p>\n<p><code><br \/>\nif (isset($_GET['inspec']) && !isset($_GET['dirone']) && !isset($_GET['dirtwo'])) {   \/\/ reserved for curl instructions<br \/>\n  \/\/ Curl usage is hard to differentiate from \"Surfing the Net\" ... they both ask for a URL whereas Command Line has arguments ... so sometimes Curl usage is best<br \/>\n\/\/        organized with one $_GET[] (for us $_GET['inspec']) and limit it to just the one.  Why so?  Well, \"&\" on command line is awkward.<br \/>\n\/\/        To involve more than one argument in Curl use an internal delimitation character like ^ or ! perhaps to proceed.  We were able to just keep it to one today.<br \/>\n\/\/<br \/>\n\/\/ ... curl argument processing code goes here<br \/>\n\/\/<br \/>\n} else if ($argv) {  \/\/ command line usage<br \/>\n\/\/<br \/>\n\/\/ ... command line argument processing code goes here<br \/>\n\/\/<br \/>\n} else {   \/\/ surfing the net usage<br \/>\n\/\/<br \/>\n\/\/ ... surfing the net argument processing code goes here<br \/>\n\/\/<br \/>\n}<br \/>\n<\/code><\/p>\n<p> &#8230; and down near the bottom, differentiation regarding the look of the outputs, it goes &#8230;<\/p>\n<p><code><br \/>\nif ($argv || (isset($_GET['inspec']) && !isset($_GET['dirone']) && !isset($_GET['dirtwo']))) { \/\/ command line or curl ... just show commands for user to try or not ... they may want a pipe like \" | tee do_these_renames.ksh\"  (and then follow up \"ksh -x do_these_renames.ksh\")<br \/>\n$outp=\"\";<br \/>\nif (strpos(strtoupper(('' . PHP_OS)), \"WINDOW\") !== false) {<br \/>\n$lines=explode(\"\\nren\" . \"ame \");<br \/>\nfor ($oi=1; $oi&lt;sizeof($lines); $oi++) {<br \/>\n  $outp.=\"ren\" . \"ame \" . explode(\"\\n\", $lines[$oi])[0] . \"\\n\";<br \/>\n}<br \/>\n} else {<br \/>\n$lines=explode(\"\\nm\" . \"v \",$htmlis);<br \/>\nfor ($oi=1; $oi&lt;sizeof($lines); $oi++) {<br \/>\n  $outp.=\"m\" . \"v \" . explode(\"\\n\", $lines[$oi])[0] . \"\\n\";<br \/>\n}<br \/>\n}<br \/>\necho $outp;<br \/>\n} else { \/\/ surfing the net form interactions below<br \/>\necho $htmlis;<br \/>\n}<br \/>\n<\/code><\/p>\n<p>If you watch the video above, you&#8217;ll see us touching on some piping ideas too, with respect to Command Line and Curl modes of use, taking place at the command line.  These modes of use just output a set of operating system proposed rename (or non-Windows mv) commands to achieve the same default decisions the Surfing the Net program first shows after you Click\/Touch the &#8220;Analyze&#8221; button.  These commands have not been done by the application, as we leave this up to the user, as much as anything because the joys of piping can be used.  Take <b>a look at<\/b> &#8230;<\/p>\n<ul>\n<li>Command Line Usage &#8230; for example, be in MAMP&#8217;s \/Applications\/MAMP\/htdocs\/ directory with &#8230; <i>php rename_to_aid_sorting.php .\/Django_Python-<\/i><b> | tee do_renames.ksh<\/b> # or &#8230;<\/li>\n<li>Curl Usage &#8230; for example, be in MAMP&#8217;s \/Applications\/MAMP\/htdocs\/ directory with &#8230; <i>curl http:\/\/localhost:8888\/rename_to_aid_sorting.php?inspec=.\/Django_Python-<\/i><b> | tee do_renames.ksh<\/b> # you can see in action below &#8230;<\/li>\n<\/ul>\n<p>To make these (default) renamings happen (and now the operating system will supply any error messages, and here, we use our favourite scripting shell on non-Windows &#8230;ksh &#8230; <a target=\"_blank\" title='korn' href='http:\/\/www.computerhope.com\/unix\/uksh.htm' rel=\"noopener\">Korn Shell<\/a>) &#8230;<\/p>\n<p><code><br \/>\nksh -x do_renames.ksh<br \/>\n<\/code><\/p>\n<p>For Windows &#8230;<\/p>\n<ul>\n<li>Command Line Usage &#8230; for example, be in MAMP&#8217;s \/Applications\/MAMP\/htdocs\/ directory with &#8230; <i>php rename_to_aid_sorting.php .\/Django_Python-<\/i><b> &gt; do_renames.bat<\/b> # or &#8230;<\/li>\n<li>Curl Usage &#8230; for example, be in MAMP&#8217;s \/Applications\/MAMP\/htdocs\/ directory with &#8230; <i>curl http:\/\/localhost:8888\/rename_to_aid_sorting.php?inspec=.\/Django_Python-<\/i><b> &gt; do_renames.bat<\/b> # you can see in action below &#8230;<\/li>\n<\/ul>\n<p>To make these (default) renamings happen, opening the Windows command line application (and now Window&#8217;s command line (DOS) operating system will supply any error messages) &#8230;<\/p>\n<p><code><br \/>\ndo_renames.bat<br \/>\n<\/code><\/p>\n<p>The third draft of <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php--GETME\" rel=\"noopener\">rename_to_aid_sorting.php<\/a>, <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php--GETME\" rel=\"noopener\">that changed this way<\/a>, can be tried, by you, at this, still, &#8220;forlornly functional, but still showing Analysis phase&#8221; (as we outlined with yesterday&#8217;s <a title='Renaming to Aid with Numerical File Sorts Primer Tutorial' href='#ranfspt'>Renaming to Aid with Numerical File Sorts Primer Tutorial<\/a>) <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php\" title=\"Click picture\" rel=\"noopener\">live run<\/a> link.  Its real power, though, is by you downloading it to a local web server environment such as MAMP supplies and code and test things yourself.  Feel free.<\/p>\n<p><b><i>Did you know?<\/i><\/b><\/p>\n<p>What is behind how PHP performs the operating system renaming commands &#8230; (good ol&#8217;) &#8230;<\/p>\n<p><code><br \/>\n<a target=\"_blank\" title='PHP glob() method information' href='http:\/\/php.net\/manual\/en\/function.exec.php' rel=\"noopener\">exec<\/a>(urldecode($_POST['cmd']));<br \/>\n<\/code><\/p>\n<p>Notice &#8220;the home of PHP&#8221;&#8216;s webpage&#8217;s blurb about alternatives &#8230;<\/p>\n<blockquote cite=\"http:\/\/php.net\/manual\/en\/function.exec.php\">\n<p>    system() &#8211; Execute an external program and display the output<br \/>\n    passthru() &#8211; Execute an external program and display raw output<br \/>\n    escapeshellcmd() &#8211; Escape shell metacharacters<br \/>\n    pcntl_exec() &#8211; Executes specified program in current process space<br \/>\n    backtick operator<\/p>\n<\/blockquote>\n<p> &#8230; and you might be interested in I.T. &#8220;land&#8221; with the word <strike><a target=\"_blank\" title='Fork information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Fork_(disambiguation)' rel=\"noopener\">fork<\/a><\/strike> <strike><a target=\"_blank\" title='Fork information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Trident' rel=\"noopener\">fork<\/a><\/strike> <strike><a target=\"_blank\" title='Fork information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Motorcycle_fork' rel=\"noopener\">fork<\/a><\/strike> <strike><a target=\"_blank\" title='Fork information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Fork' rel=\"noopener\">fork<\/a><\/strike> <strike><a target=\"_blank\" title='Fork information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Garden_fork' rel=\"noopener\">fork<\/a><\/strike> <strike><a target=\"_blank\" title='Fork information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Tuning_fork' rel=\"noopener\">fork<\/a><\/strike> <strike><a target=\"_blank\" title='Fork information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Fork_(file_system)' rel=\"noopener\">fork<\/a><\/strike> <strike><a target=\"_blank\" title='?' href='https:\/\/www.youtube.com\/watch?v=C-Ta4XbRRj4' rel=\"noopener\"><font size=1>p<\/font>ork<\/a><\/strike> &#8230; aah &#8230; <a target=\"_blank\" title='Fork information from Wikipedia, thanks' href='https:\/\/en.wikipedia.org\/wiki\/Fork_(system_call)' rel=\"noopener\">fork<\/a>.\n<\/p>\n<hr>\n<p id='ranfsat'>Previous relevant <a target=\"_blank\" title='Renaming to Aid with Numerical File Sorts Actions Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/renaming-to-aid-with-numerical-file-sorts-actions-tutorial\/' rel=\"noopener\">Renaming to Aid with Numerical File Sorts Actions Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Renaming to Aid with Numerical File Sorts Actions Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting_actions.jpg\" title=\"Renaming to Aid with Numerical File Sorts Actions Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Renaming to Aid with Numerical File Sorts Actions Tutorial<\/p><\/div>\n<p>Ah, that&#8217;s the thing!  &#8220;Actions&#8221; sounds good&#8217;n&#8217;all but <font size=1>&#8230; and didn&#8217;t you &#8230;<\/font> we can&#8217;t let anybody loose with a &#8220;fully functional&#8221; live run to the RJM Programming web server with this renaming web application.  We&#8217;ll just have to show you what the same codebase produces on our local <a target=\"_blank\" title='MAMP Mac Apache\/PHP\/MySql local web server' href='http:\/\/www.mamp.info\/' rel=\"noopener\">MAMP<\/a> (Mac) Apache\/PHP\/MySql web server in &#8220;fully functional&#8221; form.<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/idzkZ5x1DEc\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/p>\n<p>Happily, our second draft of <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php-GETME\" rel=\"noopener\">rename_to_aid_sorting.php<\/a>, <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php-GETME\" rel=\"noopener\">that changed this way<\/a>, can be tried, by you, at this &#8220;forlornly functional, but still showing Analysis phase&#8221; (as we outlined with yesterday&#8217;s <a title='Renaming to Aid with Numerical File Sorts Primer Tutorial' href='#ranfspt'>Renaming to Aid with Numerical File Sorts Primer Tutorial<\/a>) <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php\" title=\"Click picture\" rel=\"noopener\">live run<\/a> link.<\/p>\n<p>So after an initial phase of imagining how to resist bad usage thoughts, there were also more things to consider when allowing for real operating system <i>rename<\/i> commands (or <i>mv<\/i> on non-Windows operating systems), such as &#8230;<\/p>\n<ul>\n<li>error (and status) messaging &#8230; related to\n<ol>\n<li>input file does not exist<\/li>\n<li>output file already exists<\/li>\n<li>rename fails<\/li>\n<li>(else mention if successful)<\/li>\n<\/ol>\n<\/li>\n<li>individual checkboxes to allow for individual renamings (which happen at an HTML iframe &#8220;child&#8221; run of the same codebase PHP that performs an <i>exec<\/i> rename call from the (relevant) operating system (though we could have used PHP&#8217;s <a target=\"_blank\" title='PHP rename information' href='http:\/\/php.net\/manual\/en\/function.rename.php' rel=\"noopener\">rename<\/a> command to not have to differentiate via operating system, this way), the PHP&#8217;s way to tell happening via PHP_OS global)<\/li>\n<li>overall checkbox to allow for any non-checked individual checkboxes to be clicked in a batch &#8230; and if so &#8230;\n<ol>\n<li>stagger the timing of it happening so user can read a status message between <a target=\"_blank\" title='Javascript setTimeout method information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/met_win_settimeout.asp' rel=\"noopener\">setTimeout<\/a> controlled renamings<\/li>\n<li>give a report on the overall run at the end of this run<\/li>\n<li>show progress via <i>cursor:progress;<\/i> on the overall checkbox going back to <i>cursor:pointer;<\/i> at the finish<\/li>\n<\/ol>\n<\/li>\n<li>control of the individual checkbox &#8220;checked&#8221; look happens at that HTML iframe&#8217;s <i>onload<\/i> event &#8220;Client Pre-Emptive Iframe&#8221; inspired logic<\/li>\n<li>after a successful rename ensure no bad repeated action, by use of [HTMLinputTextElement].readOnly=true on middle textbox and [HTMLinputCheckboxElement].style.display=&#8217;none&#8217; on right hand side checkbox<\/li>\n<li>spaces in filenames requires double quoting delimitation<\/li>\n<\/ul>\n<p>It&#8217;s amazing how much extra thought you need to put into procedural web applications like this, because the user needs follow up information in a real sense.<\/p>\n<p><b><i>Did you know?<\/i><\/b><\/p>\n<p>What is behind how PHP takes the input entries and obtains a set of file names (we refer to as &#8220;input&#8221; files above)?   It&#8217;s done via one of our favourite PHP functions &#8230; (good ol&#8217;) &#8230;<\/p>\n<p><code><br \/>\nforeach (<a target=\"_blank\" title='PHP glob() method information' href='http:\/\/php.net\/manual\/en\/function.glob.php' rel=\"noopener\">glob<\/a>($dprefix . $asteriskybit) as $filename) {<br \/>\n   \/\/ process $filename here<br \/>\n}<br \/>\n<\/code><\/p>\n<p>Notice its abilities as far as <a target=\"_blank\" title='Useful link, thanks' href='http:\/\/teaching.idallen.com\/cst8207\/15w\/notes\/190_glob_patterns.html' rel=\"noopener\">wildcards<\/a> go &#8230; * (for any number of character)  and ? (for one character) and [0123456789] (we use in this project, for one counting number character).<\/p>\n<hr>\n<p id='ranfspt'>Previous relevant <a target=\"_blank\" title='Renaming to Aid with Numerical File Sorts Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/renaming-to-aid-with-numerical-file-sorts-primer-tutorial\/' rel=\"noopener\">Renaming to Aid with Numerical File Sorts Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php\" rel=\"noopener\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Renaming to Aid with Numerical File Sorts Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.jpg\" title=\"Renaming to Aid with Numerical File Sorts Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Renaming to Aid with Numerical File Sorts Primer Tutorial<\/p><\/div>\n<p>It&#8217;s not just the operating systems that throw up issues regarding file names with numerical parts to them that when displayed get sorted alphabetically, but you&#8217;d like it either &#8230;<\/p>\n<ul>\n<li>numerically &#8230; or &#8230;<\/li>\n<li>a hybrid of numerically and alphabetically<\/li>\n<\/ul>\n<p>We&#8217;re not there yet <font size=1>&#8230; but &#8220;are we there yet&#8221;, now? &#8230;<\/font> but we&#8217;re starting down the road to this with some PHP we&#8217;re developing.   This might be useful as a tool because sometimes with real work, you could be talking about hundreds of files needing renaming either to &#8230;<\/p>\n<ul>\n<li>suit some procedural (process) that is looking for the numbers to determine order, and yet uses defaulting file sorting algorithms &#8230; ie. what we are talking about today is a program to make it that both are satisfied, so long as the procedure doesn&#8217;t mind filenames being changed this way, to still work<\/li>\n<li>annoyance factor issues, the one that springs to mind for me being the assembly of some images that we use Mac OS X desktop application Preview to use to assemble into a PDF slideshow via being in the Mac OS X Finder and highlighting our files and running into the alphabetic\/numerical sort conundrum &#8230; annoyance only? &#8230; by that I mean, you can fix this at Preview, so it rates as an &#8220;annoyance&#8221; only<\/li>\n<\/ul>\n<p>What&#8217;s involved?  Lots &#8230; think of this in terms of prefixing the correct number of &#8220;0&#8221;&#8216;s (ie. zeroes) in the right place of the filename &#8230;<\/p>\n<ul>\n<li>the file extension &#8230; we decide not to cross across file extensions with our mini-renaming-rule sets<\/li>\n<li>the number of delimited sets before the period (ie. dot &#8220;.&#8221;) of the file extension &#8230; we decide not to cross across &#8220;file extension\/number of delimited sets before the period&#8221;s with our mini-renaming-rule sets<\/li>\n<li>the delimiter itself before the period (and if none, call it the period) &#8230; we decide not to cross across &#8220;file extension\/number of delimited sets before the period\/delimiter&#8221;s with our mini-renaming-rule sets<\/li>\n<li>how many &#8220;delimited sets before the period&#8221; to apply the renaming logic attempts onto &#8230; we&#8217;ve decided just the first for now<\/li>\n<li>what about non-numerical and non-delimiter characters before the period &#8230; hand me the <a target=\"_blank\" title='Take a Bex ... and ...' href='https:\/\/www.youtube.com\/watch?v=BF6ffbz70SY' rel=\"noopener\">Bex<\/a>, will you?!<\/li>\n<\/ul>\n<p>Our first draft of <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php_GETME\" rel=\"noopener\">rename_to_aid_sorting.php<\/a> can be tried, by you, at this <a target=\"_blank\" href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/rename_to_aid_sorting.php\" title=\"Click picture\" rel=\"noopener\">live run<\/a> link.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d37583' onclick='var dv=document.getElementById(\"d37583\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/file\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d37583' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d37604' onclick='var dv=document.getElementById(\"d37604\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/checkbox\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d37604' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d37632' onclick='var dv=document.getElementById(\"d37632\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/curl\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d37632' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d37632' onclick='var dv=document.getElementById(\"d37632\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/curl\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d37632' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We wanted to revisit the File Renaming Web Application of Renaming to Aid with Numerical File Sorts Command Line and Curl Tutorial to see if there are any &#8220;moving from&#8221; &#8230; CentOS Apache PHP version starting with a 5 \u2026 &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/renaming-to-aid-with-numerical-file-sorts-almalinux-command-line-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[4855,234,4986,932,997,1872,1173,1319],"class_list":["post-65501","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-almalinux","tag-command-line","tag-numerical-sort","tag-php","tag-programming","tag-rename","tag-sort","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/65501"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=65501"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/65501\/revisions"}],"predecessor-version":[{"id":65502,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/65501\/revisions\/65502"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=65501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=65501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=65501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}