I need some help in Shell scripting.
I have a folder with single-letter folder names starting with 1 and ending with the small letter z: [1-9A-Za-z]
.
Now, I want to rename the folders to its hexadecimal value:
1
to 31
... z
to 7A
.
I wanted to fix this with a for loop, but now I'm stuck here. I had never programmed with Shell, but with C and ASM.
[Edit]: Open your Terminfo folder. On OS X (10.9.1): /usr/share/terminfo
.
There you can see hex values.
Now, on my iPhone, they are in single ASCII characters. Therefore the terminal can't find any file.
In any appropriate directory, you can try:
If you use
echo mv
instead of justmv
, you can see the operations the shell does. You can use%2x
in place of%2X
to get names like7a
, which matches what I see in/usr/share/terminfo
on my machine (but the file system is case-preserving and case-insensitive, so the upper-case should work). You might also consider usingln -s
instead ofmv
; that way, you have both the old names and the new names available, so old code and new code should be happy.Tested on Mac OS X 10.9.1 Mavericks.