Why did my folder names end up like this, and how can I fix this using a script?How can two files in one of my folders have the same name?Select unicode filename in BashRecursively list files with file names, folder names and permissionHow can I fix this SSH hostname tab completion script?How did this '&' at the end of my command, make the script SO fast?Making a *nicely* formatted list of number of files in directories - awk & sed probablyExtract all image names with sub folder names into CSV file using shell scriptCan someone tell me what I'm doing wrong/how to fix this shell script?How to Move file using Script

Productivity/Timer app that uses twilio to send SMS-reminders

Has Donald Duck ever had any love interest besides Daisy?

Negative theta for long OTM put?

What definition takes up more memory, def or chardef (considering def contains a single character)?

Why are there so many binary systems?

Fitting data in polar coordinates

ArcMap 10.7.1: Is it still a 32-bit software

Are there any dishes that can only be cooked with a microwave?

Is the sentence "pay some in cash" understandable?

Does a resurrected wizard remember their prepared spells?

TV Pilot or Movie, 80s, misfit team with powers

When to use Sitecore.Context.Items and why?

Can I "read" from English books to my infant, but use words from my native language?

What events still occur within a transaction that gets rolled back?

Can anyone identify the aircraft in the background of this photo please?

Was it possible for a message from Paris to reach London within 48 hours in 1782?

Arabia and the Middle Ages

40 amp range outlet as extension cord source

How do critical hits work with static monster damage?

Why has no one requested the tape of the Trump/Ukraine call?

Do monthly payments decrease on a mortgage later in the loan?

Unique magic triplets

Does 5e have a Manual of the Planes?

What does Ambassador Taylor have to do with the Trump impeachment inquiry?



Why did my folder names end up like this, and how can I fix this using a script?


How can two files in one of my folders have the same name?Select unicode filename in BashRecursively list files with file names, folder names and permissionHow can I fix this SSH hostname tab completion script?How did this '&' at the end of my command, make the script SO fast?Making a *nicely* formatted list of number of files in directories - awk & sed probablyExtract all image names with sub folder names into CSV file using shell scriptCan someone tell me what I'm doing wrong/how to fix this shell script?How to Move file using Script






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









15


















Sorry if this has an answer elsewhere, I've no idea how to search for my problem.



I was running some simulations on a redhat linux HPC server, and my code for handling the folder structure to save the output had an unfortunate bug. My matlab code to create the folder was:



folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded. In fact, the simulations ran without a hitch, and the data got saved to the matching directory.



Now, when the folder structure is queried/printed I get the following situations:



  • When I try to tab autocomplete: run_ run_^A/ run_^B/ run_^C/ run_^D/ run_^E/ run_^F/ run_^G/ run_^H/ run_^I/

  • When I use ls: run_ run_? run_? run_? run_? run_? run_? run_? run_? run_? run_?.

  • When I transfer to my mac using rsync the --progress option shows: run_#003/ etc. with (I assume) the number matching the integer in sp.run_number padded to three digits, so the 10th run is run_#010/

  • When I view the folders in finder I see run_ run_ run_ run_ run_ run_ run_ run_ run_ run_?

  • Looking at this question and using the command ls | LC_ALL=C sed -n l I get:

run_$
run_01$
run_02$
run_03$
run_04$
run_05$
run_06$
run_a$
run_b$
run_t$
run_$


I can't manage to cd into the folders using any of these representations.



I have thousands of these folders, so I'll need to fix this with a script.
Which of these options is the correct representation of the folder? How can I programmatically refer to these folders so I rename them with a properly formatted name using a bash script? And I guess for the sake of curiosity, how in the hell did this happen in the first place?










share|improve this question






















  • 4





    "When I try to tab autocomplete: ... If I try to type ..." Why type and not let autocomplete complete if for you? Also ^A is not literally ^ followed by A, but Ctrl-A (you can type it using Ctrl-V Ctrl-A since Ctrl-A is generally a shortcut for the shell).

    – muru
    Aug 26 at 2:46












  • @muru that doesn't work... I get as far as run_ and I have to type something

    – Phill
    Aug 26 at 2:49











  • Sorry commented before I saw your edit, that manages to get me in via cd

    – Phill
    Aug 26 at 2:51











  • Possible duplicate of Select unicode filename in Bash

    – muru
    Aug 26 at 3:01






  • 9





    BTW, the "some reason" why mkdir in matlab did this is because the ONLY invalid characters in a file or directory name on unix filesystems are NUL and forward-slash /. Any other character is valid, including control characters. I don't know what matlab would have done if sp.run_number was 0 (probably either abort with an error or produce run_, as the NUL byte would terminate the directory name string). Of course, this would be also problematic for 16-bit (or higher) values that had a NUL byte in them, and would also vary according to the endian-ness of the system running matlab.

    – cas
    Aug 26 at 5:19


















15


















Sorry if this has an answer elsewhere, I've no idea how to search for my problem.



I was running some simulations on a redhat linux HPC server, and my code for handling the folder structure to save the output had an unfortunate bug. My matlab code to create the folder was:



folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded. In fact, the simulations ran without a hitch, and the data got saved to the matching directory.



Now, when the folder structure is queried/printed I get the following situations:



  • When I try to tab autocomplete: run_ run_^A/ run_^B/ run_^C/ run_^D/ run_^E/ run_^F/ run_^G/ run_^H/ run_^I/

  • When I use ls: run_ run_? run_? run_? run_? run_? run_? run_? run_? run_? run_?.

  • When I transfer to my mac using rsync the --progress option shows: run_#003/ etc. with (I assume) the number matching the integer in sp.run_number padded to three digits, so the 10th run is run_#010/

  • When I view the folders in finder I see run_ run_ run_ run_ run_ run_ run_ run_ run_ run_?

  • Looking at this question and using the command ls | LC_ALL=C sed -n l I get:

run_$
run_01$
run_02$
run_03$
run_04$
run_05$
run_06$
run_a$
run_b$
run_t$
run_$


I can't manage to cd into the folders using any of these representations.



I have thousands of these folders, so I'll need to fix this with a script.
Which of these options is the correct representation of the folder? How can I programmatically refer to these folders so I rename them with a properly formatted name using a bash script? And I guess for the sake of curiosity, how in the hell did this happen in the first place?










share|improve this question






















  • 4





    "When I try to tab autocomplete: ... If I try to type ..." Why type and not let autocomplete complete if for you? Also ^A is not literally ^ followed by A, but Ctrl-A (you can type it using Ctrl-V Ctrl-A since Ctrl-A is generally a shortcut for the shell).

    – muru
    Aug 26 at 2:46












  • @muru that doesn't work... I get as far as run_ and I have to type something

    – Phill
    Aug 26 at 2:49











  • Sorry commented before I saw your edit, that manages to get me in via cd

    – Phill
    Aug 26 at 2:51











  • Possible duplicate of Select unicode filename in Bash

    – muru
    Aug 26 at 3:01






  • 9





    BTW, the "some reason" why mkdir in matlab did this is because the ONLY invalid characters in a file or directory name on unix filesystems are NUL and forward-slash /. Any other character is valid, including control characters. I don't know what matlab would have done if sp.run_number was 0 (probably either abort with an error or produce run_, as the NUL byte would terminate the directory name string). Of course, this would be also problematic for 16-bit (or higher) values that had a NUL byte in them, and would also vary according to the endian-ness of the system running matlab.

    – cas
    Aug 26 at 5:19














15













15









15


1






Sorry if this has an answer elsewhere, I've no idea how to search for my problem.



I was running some simulations on a redhat linux HPC server, and my code for handling the folder structure to save the output had an unfortunate bug. My matlab code to create the folder was:



folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded. In fact, the simulations ran without a hitch, and the data got saved to the matching directory.



Now, when the folder structure is queried/printed I get the following situations:



  • When I try to tab autocomplete: run_ run_^A/ run_^B/ run_^C/ run_^D/ run_^E/ run_^F/ run_^G/ run_^H/ run_^I/

  • When I use ls: run_ run_? run_? run_? run_? run_? run_? run_? run_? run_? run_?.

  • When I transfer to my mac using rsync the --progress option shows: run_#003/ etc. with (I assume) the number matching the integer in sp.run_number padded to three digits, so the 10th run is run_#010/

  • When I view the folders in finder I see run_ run_ run_ run_ run_ run_ run_ run_ run_ run_?

  • Looking at this question and using the command ls | LC_ALL=C sed -n l I get:

run_$
run_01$
run_02$
run_03$
run_04$
run_05$
run_06$
run_a$
run_b$
run_t$
run_$


I can't manage to cd into the folders using any of these representations.



I have thousands of these folders, so I'll need to fix this with a script.
Which of these options is the correct representation of the folder? How can I programmatically refer to these folders so I rename them with a properly formatted name using a bash script? And I guess for the sake of curiosity, how in the hell did this happen in the first place?










share|improve this question
















Sorry if this has an answer elsewhere, I've no idea how to search for my problem.



I was running some simulations on a redhat linux HPC server, and my code for handling the folder structure to save the output had an unfortunate bug. My matlab code to create the folder was:



folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded. In fact, the simulations ran without a hitch, and the data got saved to the matching directory.



Now, when the folder structure is queried/printed I get the following situations:



  • When I try to tab autocomplete: run_ run_^A/ run_^B/ run_^C/ run_^D/ run_^E/ run_^F/ run_^G/ run_^H/ run_^I/

  • When I use ls: run_ run_? run_? run_? run_? run_? run_? run_? run_? run_? run_?.

  • When I transfer to my mac using rsync the --progress option shows: run_#003/ etc. with (I assume) the number matching the integer in sp.run_number padded to three digits, so the 10th run is run_#010/

  • When I view the folders in finder I see run_ run_ run_ run_ run_ run_ run_ run_ run_ run_?

  • Looking at this question and using the command ls | LC_ALL=C sed -n l I get:

run_$
run_01$
run_02$
run_03$
run_04$
run_05$
run_06$
run_a$
run_b$
run_t$
run_$


I can't manage to cd into the folders using any of these representations.



I have thousands of these folders, so I'll need to fix this with a script.
Which of these options is the correct representation of the folder? How can I programmatically refer to these folders so I rename them with a properly formatted name using a bash script? And I guess for the sake of curiosity, how in the hell did this happen in the first place?







shell-script directory ls cd-command mkdir






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 26 at 7:58







Phill

















asked Aug 26 at 2:41









PhillPhill

3933 silver badges8 bronze badges




3933 silver badges8 bronze badges










  • 4





    "When I try to tab autocomplete: ... If I try to type ..." Why type and not let autocomplete complete if for you? Also ^A is not literally ^ followed by A, but Ctrl-A (you can type it using Ctrl-V Ctrl-A since Ctrl-A is generally a shortcut for the shell).

    – muru
    Aug 26 at 2:46












  • @muru that doesn't work... I get as far as run_ and I have to type something

    – Phill
    Aug 26 at 2:49











  • Sorry commented before I saw your edit, that manages to get me in via cd

    – Phill
    Aug 26 at 2:51











  • Possible duplicate of Select unicode filename in Bash

    – muru
    Aug 26 at 3:01






  • 9





    BTW, the "some reason" why mkdir in matlab did this is because the ONLY invalid characters in a file or directory name on unix filesystems are NUL and forward-slash /. Any other character is valid, including control characters. I don't know what matlab would have done if sp.run_number was 0 (probably either abort with an error or produce run_, as the NUL byte would terminate the directory name string). Of course, this would be also problematic for 16-bit (or higher) values that had a NUL byte in them, and would also vary according to the endian-ness of the system running matlab.

    – cas
    Aug 26 at 5:19













  • 4





    "When I try to tab autocomplete: ... If I try to type ..." Why type and not let autocomplete complete if for you? Also ^A is not literally ^ followed by A, but Ctrl-A (you can type it using Ctrl-V Ctrl-A since Ctrl-A is generally a shortcut for the shell).

    – muru
    Aug 26 at 2:46












  • @muru that doesn't work... I get as far as run_ and I have to type something

    – Phill
    Aug 26 at 2:49











  • Sorry commented before I saw your edit, that manages to get me in via cd

    – Phill
    Aug 26 at 2:51











  • Possible duplicate of Select unicode filename in Bash

    – muru
    Aug 26 at 3:01






  • 9





    BTW, the "some reason" why mkdir in matlab did this is because the ONLY invalid characters in a file or directory name on unix filesystems are NUL and forward-slash /. Any other character is valid, including control characters. I don't know what matlab would have done if sp.run_number was 0 (probably either abort with an error or produce run_, as the NUL byte would terminate the directory name string). Of course, this would be also problematic for 16-bit (or higher) values that had a NUL byte in them, and would also vary according to the endian-ness of the system running matlab.

    – cas
    Aug 26 at 5:19








4




4





"When I try to tab autocomplete: ... If I try to type ..." Why type and not let autocomplete complete if for you? Also ^A is not literally ^ followed by A, but Ctrl-A (you can type it using Ctrl-V Ctrl-A since Ctrl-A is generally a shortcut for the shell).

– muru
Aug 26 at 2:46






"When I try to tab autocomplete: ... If I try to type ..." Why type and not let autocomplete complete if for you? Also ^A is not literally ^ followed by A, but Ctrl-A (you can type it using Ctrl-V Ctrl-A since Ctrl-A is generally a shortcut for the shell).

– muru
Aug 26 at 2:46














@muru that doesn't work... I get as far as run_ and I have to type something

– Phill
Aug 26 at 2:49





@muru that doesn't work... I get as far as run_ and I have to type something

– Phill
Aug 26 at 2:49













Sorry commented before I saw your edit, that manages to get me in via cd

– Phill
Aug 26 at 2:51





Sorry commented before I saw your edit, that manages to get me in via cd

– Phill
Aug 26 at 2:51













Possible duplicate of Select unicode filename in Bash

– muru
Aug 26 at 3:01





Possible duplicate of Select unicode filename in Bash

– muru
Aug 26 at 3:01




9




9





BTW, the "some reason" why mkdir in matlab did this is because the ONLY invalid characters in a file or directory name on unix filesystems are NUL and forward-slash /. Any other character is valid, including control characters. I don't know what matlab would have done if sp.run_number was 0 (probably either abort with an error or produce run_, as the NUL byte would terminate the directory name string). Of course, this would be also problematic for 16-bit (or higher) values that had a NUL byte in them, and would also vary according to the endian-ness of the system running matlab.

– cas
Aug 26 at 5:19






BTW, the "some reason" why mkdir in matlab did this is because the ONLY invalid characters in a file or directory name on unix filesystems are NUL and forward-slash /. Any other character is valid, including control characters. I don't know what matlab would have done if sp.run_number was 0 (probably either abort with an error or produce run_, as the NUL byte would terminate the directory name string). Of course, this would be also problematic for 16-bit (or higher) values that had a NUL byte in them, and would also vary according to the endian-ness of the system running matlab.

– cas
Aug 26 at 5:19











3 Answers
3






active

oldest

votes


















26



















You can use the perl rename utility (aka prename or file-rename) to rename the directories.



NOTE: This is not to be confused with rename from util-linux, or any other version.



rename -n 's/([[:cntrl:]])/ord($1)/eg' run_*/


This uses perl's ord() function to replace each control-character in the filename with the ordinal number for that character. e.g ^A becomes 1, ^B becomes 2, etc.



The -n option is for a dry-run to show what rename would do if you let it. Remove it (or replace it with -v for verbose output) to actually rename.



The e modifier in the s/LHS/RHS/eg operation causes perl to execute the RHS (the replacement) as perl code, and the $1 is the matched data (the control character) from the LHS.



If you want zero-padded numbers in the filenames, you could combine ord() with sprintf(). e.g.



$ rename -n 's/([[:cntrl:]])/sprintf("%02i",ord($1))/eg' run_*/ | sed -n l
rename(run_01, run_01)$
rename(run_02, run_02)$
rename(run_03, run_03)$
rename(run_04, run_04)$
rename(run_05, run_05)$
rename(run_06, run_06)$
rename(run_a, run_07)$
rename(run_b, run_08)$
rename(run_t, run_09)$


The above examples work if and only if sp.run_number in your matlab script was in the range of 0..26 (so it produced control-characters in the directory names).



To deal with ANY 1-byte character (i.e. from 0..255), you'd use:



rename -n 's/run_(.)/sprintf("run_%03i",ord($1))/e' run_*/


If sp.run_number could be > 255, you'd have to use perl's unpack() function instead of ord(). I don't know exactly how matlab outputs an unconverted int in a string, so you'll have to experiment. See perldoc -f unpack for details.



e.g. the following will unpack both 8-bit and 16-bit unsigned values and zero-pad them to 5 digits wide:



 rename -n 's/run_(.*)/sprintf("run_%05i",unpack("SC",$1))/e' run_*/





share|improve this answer




























  • Thanks for the details! I'm trying to test it out with the -n option, but it's telling me its an invalid option - the version information gives me rename from util-linux 2.23.2 so I'mnot sure its the same function

    – Phill
    Aug 26 at 4:29






  • 3





    that's why i specified the perl version of the rename utility. util-linux's rename is very different, far less capable, and the command line options are incompatible. if you're running debian or similar, try installing the file-rename package. otherwise install the appropriate package for your distro. it may already be installed, try running prename or file-rename instead of just rename.

    – cas
    Aug 26 at 4:31












  • Yeah I thought that was the case. I'll see if I can get one of those to work. Thanks again for taking the time to help me out!

    – Phill
    Aug 26 at 4:34


















11




















And I guess for the sake of curiosity, how in the heck did this happen in the first place?



folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded.




So, it would appear that mkdir([...]) in Matlab concatenates the members of the array to build the filename as a string. But you gave it a number instead, and numbers are what the characters on a computer really are. So, when sp.run_number was 1, it gave you the character with value 1, and then the character with value 2, etc.



Those are control characters, they don't have printable symbols, and printing them on a terminal would have other consequences. So instead, they're often represented by different sorts of escapes: 01 (octal), x01 (hex), ^A are all common representations for the character with value 1. The character with value zero is a bit different, it's the NUL byte that is used to mark the end of a string in C and in the Unix system calls.



If you went higher than 31, you'd start to see printable characters, 32 is space (not very visible though), 33 = !, 34 = " etc.



So,



  • run_ run_^A/ run_^B/ — The first run_ corresponds to the one with a zero byte, the string ends there. The others show that your shell likes to use display the control codes with ^A. The notation also hints at the fact that the char with numerical value 1 can be entered as Ctrl-A, though you need to tell the shell to interpret as not as a control character, but as a literal, Ctrl-V Ctrl-A should do that at least in Bash.


  • ls: run_ run_? run_?ls doesn't like to print unprintable characters on the terminal, it replaces them with question marks.


  • rsync: run_#003/ — that one's new to me, but the idea is the same, the backslash marks an escape, and the rest is the numerical value of the character. It seems to me that the number here is in octal, like in the more common 03.


  • using the command ls | LC_ALL=C sed -n l ... run_06$
    run_a$ run_b$ run_t$a, b and t are C escapes for alarm (bell), backspace and tab, respectively. They have the numerical values 7, 8 and 9, so it should be clear why they come after 06. Using those C escapes is yet another way to mark the control characters. The trailing dollar signs mark the line ends.


As for cd, assuming my assumptions are right, cd run_ should go to that one single directory without an odd trailing character, and cd run_? should give an error since the question mark is a glob character that matches any single character, and there are multiple matching filenames, but cd only expects one.




Which of these options is the correct representation of the folder?




All of them, in a sense...



In Bash, you can use the 00 and x00 escapes inside $'...' quotes to represent the special characters, so $'run_33 (octal) or $'run_x1b' correspond to the directory with the character value 27 (which happens to be ESC).
(I don't think Bash supports escapes with decimal numbers.)



cas's answer has a script to rename those, so I won't go there.






share|improve this answer




























  • If it's GNU ls, there are some quoting options including -b/--escape and --quoting-style=, or the QUOTING_STYLE environment variable, to control how non-printing characters are shown. I don't think there's an option to make it prefer octal escapes over the character versions, though.

    – Toby Speight
    Aug 27 at 16:19


















3



















Easiest would be to create the wrong filename and the correct filename in the same environment where the mishap happened, and then just move/rename the folders to the correct names.



To avoid collisions between existing names better use another destination folder.



./saveLocationA/wrongname1 -> ./saveLocationB/correctname1
./saveLocationA/wrongname2 -> ./saveLocationB/correctname2
./saveLocationA/wrongname3 -> ./saveLocationB/correctname3


If possible, I would prefer fixing the script and just running it again; fixing some weird bug post mortem probably costs more and can introduce new problems.



Good luck!






share|improve this answer





























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );














    draft saved

    draft discarded
















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f537413%2fwhy-did-my-folder-names-end-up-like-this-and-how-can-i-fix-this-using-a-script%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown


























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    26



















    You can use the perl rename utility (aka prename or file-rename) to rename the directories.



    NOTE: This is not to be confused with rename from util-linux, or any other version.



    rename -n 's/([[:cntrl:]])/ord($1)/eg' run_*/


    This uses perl's ord() function to replace each control-character in the filename with the ordinal number for that character. e.g ^A becomes 1, ^B becomes 2, etc.



    The -n option is for a dry-run to show what rename would do if you let it. Remove it (or replace it with -v for verbose output) to actually rename.



    The e modifier in the s/LHS/RHS/eg operation causes perl to execute the RHS (the replacement) as perl code, and the $1 is the matched data (the control character) from the LHS.



    If you want zero-padded numbers in the filenames, you could combine ord() with sprintf(). e.g.



    $ rename -n 's/([[:cntrl:]])/sprintf("%02i",ord($1))/eg' run_*/ | sed -n l
    rename(run_01, run_01)$
    rename(run_02, run_02)$
    rename(run_03, run_03)$
    rename(run_04, run_04)$
    rename(run_05, run_05)$
    rename(run_06, run_06)$
    rename(run_a, run_07)$
    rename(run_b, run_08)$
    rename(run_t, run_09)$


    The above examples work if and only if sp.run_number in your matlab script was in the range of 0..26 (so it produced control-characters in the directory names).



    To deal with ANY 1-byte character (i.e. from 0..255), you'd use:



    rename -n 's/run_(.)/sprintf("run_%03i",ord($1))/e' run_*/


    If sp.run_number could be > 255, you'd have to use perl's unpack() function instead of ord(). I don't know exactly how matlab outputs an unconverted int in a string, so you'll have to experiment. See perldoc -f unpack for details.



    e.g. the following will unpack both 8-bit and 16-bit unsigned values and zero-pad them to 5 digits wide:



     rename -n 's/run_(.*)/sprintf("run_%05i",unpack("SC",$1))/e' run_*/





    share|improve this answer




























    • Thanks for the details! I'm trying to test it out with the -n option, but it's telling me its an invalid option - the version information gives me rename from util-linux 2.23.2 so I'mnot sure its the same function

      – Phill
      Aug 26 at 4:29






    • 3





      that's why i specified the perl version of the rename utility. util-linux's rename is very different, far less capable, and the command line options are incompatible. if you're running debian or similar, try installing the file-rename package. otherwise install the appropriate package for your distro. it may already be installed, try running prename or file-rename instead of just rename.

      – cas
      Aug 26 at 4:31












    • Yeah I thought that was the case. I'll see if I can get one of those to work. Thanks again for taking the time to help me out!

      – Phill
      Aug 26 at 4:34















    26



















    You can use the perl rename utility (aka prename or file-rename) to rename the directories.



    NOTE: This is not to be confused with rename from util-linux, or any other version.



    rename -n 's/([[:cntrl:]])/ord($1)/eg' run_*/


    This uses perl's ord() function to replace each control-character in the filename with the ordinal number for that character. e.g ^A becomes 1, ^B becomes 2, etc.



    The -n option is for a dry-run to show what rename would do if you let it. Remove it (or replace it with -v for verbose output) to actually rename.



    The e modifier in the s/LHS/RHS/eg operation causes perl to execute the RHS (the replacement) as perl code, and the $1 is the matched data (the control character) from the LHS.



    If you want zero-padded numbers in the filenames, you could combine ord() with sprintf(). e.g.



    $ rename -n 's/([[:cntrl:]])/sprintf("%02i",ord($1))/eg' run_*/ | sed -n l
    rename(run_01, run_01)$
    rename(run_02, run_02)$
    rename(run_03, run_03)$
    rename(run_04, run_04)$
    rename(run_05, run_05)$
    rename(run_06, run_06)$
    rename(run_a, run_07)$
    rename(run_b, run_08)$
    rename(run_t, run_09)$


    The above examples work if and only if sp.run_number in your matlab script was in the range of 0..26 (so it produced control-characters in the directory names).



    To deal with ANY 1-byte character (i.e. from 0..255), you'd use:



    rename -n 's/run_(.)/sprintf("run_%03i",ord($1))/e' run_*/


    If sp.run_number could be > 255, you'd have to use perl's unpack() function instead of ord(). I don't know exactly how matlab outputs an unconverted int in a string, so you'll have to experiment. See perldoc -f unpack for details.



    e.g. the following will unpack both 8-bit and 16-bit unsigned values and zero-pad them to 5 digits wide:



     rename -n 's/run_(.*)/sprintf("run_%05i",unpack("SC",$1))/e' run_*/





    share|improve this answer




























    • Thanks for the details! I'm trying to test it out with the -n option, but it's telling me its an invalid option - the version information gives me rename from util-linux 2.23.2 so I'mnot sure its the same function

      – Phill
      Aug 26 at 4:29






    • 3





      that's why i specified the perl version of the rename utility. util-linux's rename is very different, far less capable, and the command line options are incompatible. if you're running debian or similar, try installing the file-rename package. otherwise install the appropriate package for your distro. it may already be installed, try running prename or file-rename instead of just rename.

      – cas
      Aug 26 at 4:31












    • Yeah I thought that was the case. I'll see if I can get one of those to work. Thanks again for taking the time to help me out!

      – Phill
      Aug 26 at 4:34













    26















    26











    26









    You can use the perl rename utility (aka prename or file-rename) to rename the directories.



    NOTE: This is not to be confused with rename from util-linux, or any other version.



    rename -n 's/([[:cntrl:]])/ord($1)/eg' run_*/


    This uses perl's ord() function to replace each control-character in the filename with the ordinal number for that character. e.g ^A becomes 1, ^B becomes 2, etc.



    The -n option is for a dry-run to show what rename would do if you let it. Remove it (or replace it with -v for verbose output) to actually rename.



    The e modifier in the s/LHS/RHS/eg operation causes perl to execute the RHS (the replacement) as perl code, and the $1 is the matched data (the control character) from the LHS.



    If you want zero-padded numbers in the filenames, you could combine ord() with sprintf(). e.g.



    $ rename -n 's/([[:cntrl:]])/sprintf("%02i",ord($1))/eg' run_*/ | sed -n l
    rename(run_01, run_01)$
    rename(run_02, run_02)$
    rename(run_03, run_03)$
    rename(run_04, run_04)$
    rename(run_05, run_05)$
    rename(run_06, run_06)$
    rename(run_a, run_07)$
    rename(run_b, run_08)$
    rename(run_t, run_09)$


    The above examples work if and only if sp.run_number in your matlab script was in the range of 0..26 (so it produced control-characters in the directory names).



    To deal with ANY 1-byte character (i.e. from 0..255), you'd use:



    rename -n 's/run_(.)/sprintf("run_%03i",ord($1))/e' run_*/


    If sp.run_number could be > 255, you'd have to use perl's unpack() function instead of ord(). I don't know exactly how matlab outputs an unconverted int in a string, so you'll have to experiment. See perldoc -f unpack for details.



    e.g. the following will unpack both 8-bit and 16-bit unsigned values and zero-pad them to 5 digits wide:



     rename -n 's/run_(.*)/sprintf("run_%05i",unpack("SC",$1))/e' run_*/





    share|improve this answer
















    You can use the perl rename utility (aka prename or file-rename) to rename the directories.



    NOTE: This is not to be confused with rename from util-linux, or any other version.



    rename -n 's/([[:cntrl:]])/ord($1)/eg' run_*/


    This uses perl's ord() function to replace each control-character in the filename with the ordinal number for that character. e.g ^A becomes 1, ^B becomes 2, etc.



    The -n option is for a dry-run to show what rename would do if you let it. Remove it (or replace it with -v for verbose output) to actually rename.



    The e modifier in the s/LHS/RHS/eg operation causes perl to execute the RHS (the replacement) as perl code, and the $1 is the matched data (the control character) from the LHS.



    If you want zero-padded numbers in the filenames, you could combine ord() with sprintf(). e.g.



    $ rename -n 's/([[:cntrl:]])/sprintf("%02i",ord($1))/eg' run_*/ | sed -n l
    rename(run_01, run_01)$
    rename(run_02, run_02)$
    rename(run_03, run_03)$
    rename(run_04, run_04)$
    rename(run_05, run_05)$
    rename(run_06, run_06)$
    rename(run_a, run_07)$
    rename(run_b, run_08)$
    rename(run_t, run_09)$


    The above examples work if and only if sp.run_number in your matlab script was in the range of 0..26 (so it produced control-characters in the directory names).



    To deal with ANY 1-byte character (i.e. from 0..255), you'd use:



    rename -n 's/run_(.)/sprintf("run_%03i",ord($1))/e' run_*/


    If sp.run_number could be > 255, you'd have to use perl's unpack() function instead of ord(). I don't know exactly how matlab outputs an unconverted int in a string, so you'll have to experiment. See perldoc -f unpack for details.



    e.g. the following will unpack both 8-bit and 16-bit unsigned values and zero-pad them to 5 digits wide:



     rename -n 's/run_(.*)/sprintf("run_%05i",unpack("SC",$1))/e' run_*/






    share|improve this answer















    share|improve this answer




    share|improve this answer








    edited Aug 26 at 5:02

























    answered Aug 26 at 4:07









    cascas

    45.5k5 gold badges69 silver badges122 bronze badges




    45.5k5 gold badges69 silver badges122 bronze badges















    • Thanks for the details! I'm trying to test it out with the -n option, but it's telling me its an invalid option - the version information gives me rename from util-linux 2.23.2 so I'mnot sure its the same function

      – Phill
      Aug 26 at 4:29






    • 3





      that's why i specified the perl version of the rename utility. util-linux's rename is very different, far less capable, and the command line options are incompatible. if you're running debian or similar, try installing the file-rename package. otherwise install the appropriate package for your distro. it may already be installed, try running prename or file-rename instead of just rename.

      – cas
      Aug 26 at 4:31












    • Yeah I thought that was the case. I'll see if I can get one of those to work. Thanks again for taking the time to help me out!

      – Phill
      Aug 26 at 4:34

















    • Thanks for the details! I'm trying to test it out with the -n option, but it's telling me its an invalid option - the version information gives me rename from util-linux 2.23.2 so I'mnot sure its the same function

      – Phill
      Aug 26 at 4:29






    • 3





      that's why i specified the perl version of the rename utility. util-linux's rename is very different, far less capable, and the command line options are incompatible. if you're running debian or similar, try installing the file-rename package. otherwise install the appropriate package for your distro. it may already be installed, try running prename or file-rename instead of just rename.

      – cas
      Aug 26 at 4:31












    • Yeah I thought that was the case. I'll see if I can get one of those to work. Thanks again for taking the time to help me out!

      – Phill
      Aug 26 at 4:34
















    Thanks for the details! I'm trying to test it out with the -n option, but it's telling me its an invalid option - the version information gives me rename from util-linux 2.23.2 so I'mnot sure its the same function

    – Phill
    Aug 26 at 4:29





    Thanks for the details! I'm trying to test it out with the -n option, but it's telling me its an invalid option - the version information gives me rename from util-linux 2.23.2 so I'mnot sure its the same function

    – Phill
    Aug 26 at 4:29




    3




    3





    that's why i specified the perl version of the rename utility. util-linux's rename is very different, far less capable, and the command line options are incompatible. if you're running debian or similar, try installing the file-rename package. otherwise install the appropriate package for your distro. it may already be installed, try running prename or file-rename instead of just rename.

    – cas
    Aug 26 at 4:31






    that's why i specified the perl version of the rename utility. util-linux's rename is very different, far less capable, and the command line options are incompatible. if you're running debian or similar, try installing the file-rename package. otherwise install the appropriate package for your distro. it may already be installed, try running prename or file-rename instead of just rename.

    – cas
    Aug 26 at 4:31














    Yeah I thought that was the case. I'll see if I can get one of those to work. Thanks again for taking the time to help me out!

    – Phill
    Aug 26 at 4:34





    Yeah I thought that was the case. I'll see if I can get one of those to work. Thanks again for taking the time to help me out!

    – Phill
    Aug 26 at 4:34













    11




















    And I guess for the sake of curiosity, how in the heck did this happen in the first place?



    folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


    where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded.




    So, it would appear that mkdir([...]) in Matlab concatenates the members of the array to build the filename as a string. But you gave it a number instead, and numbers are what the characters on a computer really are. So, when sp.run_number was 1, it gave you the character with value 1, and then the character with value 2, etc.



    Those are control characters, they don't have printable symbols, and printing them on a terminal would have other consequences. So instead, they're often represented by different sorts of escapes: 01 (octal), x01 (hex), ^A are all common representations for the character with value 1. The character with value zero is a bit different, it's the NUL byte that is used to mark the end of a string in C and in the Unix system calls.



    If you went higher than 31, you'd start to see printable characters, 32 is space (not very visible though), 33 = !, 34 = " etc.



    So,



    • run_ run_^A/ run_^B/ — The first run_ corresponds to the one with a zero byte, the string ends there. The others show that your shell likes to use display the control codes with ^A. The notation also hints at the fact that the char with numerical value 1 can be entered as Ctrl-A, though you need to tell the shell to interpret as not as a control character, but as a literal, Ctrl-V Ctrl-A should do that at least in Bash.


    • ls: run_ run_? run_?ls doesn't like to print unprintable characters on the terminal, it replaces them with question marks.


    • rsync: run_#003/ — that one's new to me, but the idea is the same, the backslash marks an escape, and the rest is the numerical value of the character. It seems to me that the number here is in octal, like in the more common 03.


    • using the command ls | LC_ALL=C sed -n l ... run_06$
      run_a$ run_b$ run_t$a, b and t are C escapes for alarm (bell), backspace and tab, respectively. They have the numerical values 7, 8 and 9, so it should be clear why they come after 06. Using those C escapes is yet another way to mark the control characters. The trailing dollar signs mark the line ends.


    As for cd, assuming my assumptions are right, cd run_ should go to that one single directory without an odd trailing character, and cd run_? should give an error since the question mark is a glob character that matches any single character, and there are multiple matching filenames, but cd only expects one.




    Which of these options is the correct representation of the folder?




    All of them, in a sense...



    In Bash, you can use the 00 and x00 escapes inside $'...' quotes to represent the special characters, so $'run_33 (octal) or $'run_x1b' correspond to the directory with the character value 27 (which happens to be ESC).
    (I don't think Bash supports escapes with decimal numbers.)



    cas's answer has a script to rename those, so I won't go there.






    share|improve this answer




























    • If it's GNU ls, there are some quoting options including -b/--escape and --quoting-style=, or the QUOTING_STYLE environment variable, to control how non-printing characters are shown. I don't think there's an option to make it prefer octal escapes over the character versions, though.

      – Toby Speight
      Aug 27 at 16:19















    11




















    And I guess for the sake of curiosity, how in the heck did this happen in the first place?



    folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


    where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded.




    So, it would appear that mkdir([...]) in Matlab concatenates the members of the array to build the filename as a string. But you gave it a number instead, and numbers are what the characters on a computer really are. So, when sp.run_number was 1, it gave you the character with value 1, and then the character with value 2, etc.



    Those are control characters, they don't have printable symbols, and printing them on a terminal would have other consequences. So instead, they're often represented by different sorts of escapes: 01 (octal), x01 (hex), ^A are all common representations for the character with value 1. The character with value zero is a bit different, it's the NUL byte that is used to mark the end of a string in C and in the Unix system calls.



    If you went higher than 31, you'd start to see printable characters, 32 is space (not very visible though), 33 = !, 34 = " etc.



    So,



    • run_ run_^A/ run_^B/ — The first run_ corresponds to the one with a zero byte, the string ends there. The others show that your shell likes to use display the control codes with ^A. The notation also hints at the fact that the char with numerical value 1 can be entered as Ctrl-A, though you need to tell the shell to interpret as not as a control character, but as a literal, Ctrl-V Ctrl-A should do that at least in Bash.


    • ls: run_ run_? run_?ls doesn't like to print unprintable characters on the terminal, it replaces them with question marks.


    • rsync: run_#003/ — that one's new to me, but the idea is the same, the backslash marks an escape, and the rest is the numerical value of the character. It seems to me that the number here is in octal, like in the more common 03.


    • using the command ls | LC_ALL=C sed -n l ... run_06$
      run_a$ run_b$ run_t$a, b and t are C escapes for alarm (bell), backspace and tab, respectively. They have the numerical values 7, 8 and 9, so it should be clear why they come after 06. Using those C escapes is yet another way to mark the control characters. The trailing dollar signs mark the line ends.


    As for cd, assuming my assumptions are right, cd run_ should go to that one single directory without an odd trailing character, and cd run_? should give an error since the question mark is a glob character that matches any single character, and there are multiple matching filenames, but cd only expects one.




    Which of these options is the correct representation of the folder?




    All of them, in a sense...



    In Bash, you can use the 00 and x00 escapes inside $'...' quotes to represent the special characters, so $'run_33 (octal) or $'run_x1b' correspond to the directory with the character value 27 (which happens to be ESC).
    (I don't think Bash supports escapes with decimal numbers.)



    cas's answer has a script to rename those, so I won't go there.






    share|improve this answer




























    • If it's GNU ls, there are some quoting options including -b/--escape and --quoting-style=, or the QUOTING_STYLE environment variable, to control how non-printing characters are shown. I don't think there's an option to make it prefer octal escapes over the character versions, though.

      – Toby Speight
      Aug 27 at 16:19













    11















    11











    11










    And I guess for the sake of curiosity, how in the heck did this happen in the first place?



    folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


    where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded.




    So, it would appear that mkdir([...]) in Matlab concatenates the members of the array to build the filename as a string. But you gave it a number instead, and numbers are what the characters on a computer really are. So, when sp.run_number was 1, it gave you the character with value 1, and then the character with value 2, etc.



    Those are control characters, they don't have printable symbols, and printing them on a terminal would have other consequences. So instead, they're often represented by different sorts of escapes: 01 (octal), x01 (hex), ^A are all common representations for the character with value 1. The character with value zero is a bit different, it's the NUL byte that is used to mark the end of a string in C and in the Unix system calls.



    If you went higher than 31, you'd start to see printable characters, 32 is space (not very visible though), 33 = !, 34 = " etc.



    So,



    • run_ run_^A/ run_^B/ — The first run_ corresponds to the one with a zero byte, the string ends there. The others show that your shell likes to use display the control codes with ^A. The notation also hints at the fact that the char with numerical value 1 can be entered as Ctrl-A, though you need to tell the shell to interpret as not as a control character, but as a literal, Ctrl-V Ctrl-A should do that at least in Bash.


    • ls: run_ run_? run_?ls doesn't like to print unprintable characters on the terminal, it replaces them with question marks.


    • rsync: run_#003/ — that one's new to me, but the idea is the same, the backslash marks an escape, and the rest is the numerical value of the character. It seems to me that the number here is in octal, like in the more common 03.


    • using the command ls | LC_ALL=C sed -n l ... run_06$
      run_a$ run_b$ run_t$a, b and t are C escapes for alarm (bell), backspace and tab, respectively. They have the numerical values 7, 8 and 9, so it should be clear why they come after 06. Using those C escapes is yet another way to mark the control characters. The trailing dollar signs mark the line ends.


    As for cd, assuming my assumptions are right, cd run_ should go to that one single directory without an odd trailing character, and cd run_? should give an error since the question mark is a glob character that matches any single character, and there are multiple matching filenames, but cd only expects one.




    Which of these options is the correct representation of the folder?




    All of them, in a sense...



    In Bash, you can use the 00 and x00 escapes inside $'...' quotes to represent the special characters, so $'run_33 (octal) or $'run_x1b' correspond to the directory with the character value 27 (which happens to be ESC).
    (I don't think Bash supports escapes with decimal numbers.)



    cas's answer has a script to rename those, so I won't go there.






    share|improve this answer

















    And I guess for the sake of curiosity, how in the heck did this happen in the first place?



    folder = [sp.saveLocation, 'run_', sp.run_number, '/'];


    where sp.run_number was an integer. I forgot to convert it to a string, but for some reason running mkdir(folder); (in matlab) still succeeded.




    So, it would appear that mkdir([...]) in Matlab concatenates the members of the array to build the filename as a string. But you gave it a number instead, and numbers are what the characters on a computer really are. So, when sp.run_number was 1, it gave you the character with value 1, and then the character with value 2, etc.



    Those are control characters, they don't have printable symbols, and printing them on a terminal would have other consequences. So instead, they're often represented by different sorts of escapes: 01 (octal), x01 (hex), ^A are all common representations for the character with value 1. The character with value zero is a bit different, it's the NUL byte that is used to mark the end of a string in C and in the Unix system calls.



    If you went higher than 31, you'd start to see printable characters, 32 is space (not very visible though), 33 = !, 34 = " etc.



    So,



    • run_ run_^A/ run_^B/ — The first run_ corresponds to the one with a zero byte, the string ends there. The others show that your shell likes to use display the control codes with ^A. The notation also hints at the fact that the char with numerical value 1 can be entered as Ctrl-A, though you need to tell the shell to interpret as not as a control character, but as a literal, Ctrl-V Ctrl-A should do that at least in Bash.


    • ls: run_ run_? run_?ls doesn't like to print unprintable characters on the terminal, it replaces them with question marks.


    • rsync: run_#003/ — that one's new to me, but the idea is the same, the backslash marks an escape, and the rest is the numerical value of the character. It seems to me that the number here is in octal, like in the more common 03.


    • using the command ls | LC_ALL=C sed -n l ... run_06$
      run_a$ run_b$ run_t$a, b and t are C escapes for alarm (bell), backspace and tab, respectively. They have the numerical values 7, 8 and 9, so it should be clear why they come after 06. Using those C escapes is yet another way to mark the control characters. The trailing dollar signs mark the line ends.


    As for cd, assuming my assumptions are right, cd run_ should go to that one single directory without an odd trailing character, and cd run_? should give an error since the question mark is a glob character that matches any single character, and there are multiple matching filenames, but cd only expects one.




    Which of these options is the correct representation of the folder?




    All of them, in a sense...



    In Bash, you can use the 00 and x00 escapes inside $'...' quotes to represent the special characters, so $'run_33 (octal) or $'run_x1b' correspond to the directory with the character value 27 (which happens to be ESC).
    (I don't think Bash supports escapes with decimal numbers.)



    cas's answer has a script to rename those, so I won't go there.







    share|improve this answer















    share|improve this answer




    share|improve this answer








    edited Aug 27 at 5:40

























    answered Aug 26 at 12:18









    ilkkachuilkkachu

    72k11 gold badges119 silver badges210 bronze badges




    72k11 gold badges119 silver badges210 bronze badges















    • If it's GNU ls, there are some quoting options including -b/--escape and --quoting-style=, or the QUOTING_STYLE environment variable, to control how non-printing characters are shown. I don't think there's an option to make it prefer octal escapes over the character versions, though.

      – Toby Speight
      Aug 27 at 16:19

















    • If it's GNU ls, there are some quoting options including -b/--escape and --quoting-style=, or the QUOTING_STYLE environment variable, to control how non-printing characters are shown. I don't think there's an option to make it prefer octal escapes over the character versions, though.

      – Toby Speight
      Aug 27 at 16:19
















    If it's GNU ls, there are some quoting options including -b/--escape and --quoting-style=, or the QUOTING_STYLE environment variable, to control how non-printing characters are shown. I don't think there's an option to make it prefer octal escapes over the character versions, though.

    – Toby Speight
    Aug 27 at 16:19





    If it's GNU ls, there are some quoting options including -b/--escape and --quoting-style=, or the QUOTING_STYLE environment variable, to control how non-printing characters are shown. I don't think there's an option to make it prefer octal escapes over the character versions, though.

    – Toby Speight
    Aug 27 at 16:19











    3



















    Easiest would be to create the wrong filename and the correct filename in the same environment where the mishap happened, and then just move/rename the folders to the correct names.



    To avoid collisions between existing names better use another destination folder.



    ./saveLocationA/wrongname1 -> ./saveLocationB/correctname1
    ./saveLocationA/wrongname2 -> ./saveLocationB/correctname2
    ./saveLocationA/wrongname3 -> ./saveLocationB/correctname3


    If possible, I would prefer fixing the script and just running it again; fixing some weird bug post mortem probably costs more and can introduce new problems.



    Good luck!






    share|improve this answer
































      3



















      Easiest would be to create the wrong filename and the correct filename in the same environment where the mishap happened, and then just move/rename the folders to the correct names.



      To avoid collisions between existing names better use another destination folder.



      ./saveLocationA/wrongname1 -> ./saveLocationB/correctname1
      ./saveLocationA/wrongname2 -> ./saveLocationB/correctname2
      ./saveLocationA/wrongname3 -> ./saveLocationB/correctname3


      If possible, I would prefer fixing the script and just running it again; fixing some weird bug post mortem probably costs more and can introduce new problems.



      Good luck!






      share|improve this answer






























        3















        3











        3









        Easiest would be to create the wrong filename and the correct filename in the same environment where the mishap happened, and then just move/rename the folders to the correct names.



        To avoid collisions between existing names better use another destination folder.



        ./saveLocationA/wrongname1 -> ./saveLocationB/correctname1
        ./saveLocationA/wrongname2 -> ./saveLocationB/correctname2
        ./saveLocationA/wrongname3 -> ./saveLocationB/correctname3


        If possible, I would prefer fixing the script and just running it again; fixing some weird bug post mortem probably costs more and can introduce new problems.



        Good luck!






        share|improve this answer
















        Easiest would be to create the wrong filename and the correct filename in the same environment where the mishap happened, and then just move/rename the folders to the correct names.



        To avoid collisions between existing names better use another destination folder.



        ./saveLocationA/wrongname1 -> ./saveLocationB/correctname1
        ./saveLocationA/wrongname2 -> ./saveLocationB/correctname2
        ./saveLocationA/wrongname3 -> ./saveLocationB/correctname3


        If possible, I would prefer fixing the script and just running it again; fixing some weird bug post mortem probably costs more and can introduce new problems.



        Good luck!







        share|improve this answer















        share|improve this answer




        share|improve this answer








        edited Sep 1 at 11:20









        Jeff Schaller

        52k11 gold badges76 silver badges172 bronze badges




        52k11 gold badges76 silver badges172 bronze badges










        answered Aug 26 at 21:26









        PeterPeter

        311 bronze badge




        311 bronze badge































            draft saved

            draft discarded















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f537413%2fwhy-did-my-folder-names-end-up-like-this-and-how-can-i-fix-this-using-a-script%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown









            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?