Bash – Rename Hidden Directories Created by GNU Parallel

bashdirectorygnu-parallel

GNU Parallel is outputting hidden directories as follows using the --results parameter.

What command do I use on Ubuntu to change the all to directories so that they are no longer hidden. The directories are called:

'.\_ValidateAll.sh GL 170'/
'.\_ValidateAll.sh GL 190'/
'.\_ValidateAll.sh GL 220'/
'.\_ValidateAll.sh GL 355'/
'.\_ValidateAll.sh GL 357'/
'.\_ValidateAll.sh GL 359'/
'.\_ValidateAll.sh GL 361'/
'.\_ValidateAll.sh GL 363'/

enter image description here

Actually when I do a cat on the directory, I don't see the single quotes

vmdovs@ubuntu:/mnt/out/1$ cat 
GL170/                    .\_ValidateAll.sh GL 357/ .\_ValidateAll.sh GL 390/ .\_ValidateAll.sh GL 470/ .\_ValidateAll.sh GL 570/
rename.sh                 .\_ValidateAll.sh GL 359/ .\_ValidateAll.sh GL 400/ .\_ValidateAll.sh GL 480/ .\_ValidateAll.sh GL 572/
.\_ValidateAll.sh GL 190/ .\_ValidateAll.sh GL 361/ .\_ValidateAll.sh GL 410/ .\_ValidateAll.sh GL 500/ .\_ValidateAll.sh GL 574/
.\_ValidateAll.sh GL 220/ .\_ValidateAll.sh GL 363/ .\_ValidateAll.sh GL 420/ .\_ValidateAll.sh GL 530/ .\_ValidateAll.sh GL 590/
.\_ValidateAll.sh GL 355/ .\_ValidateAll.sh GL 368/ .\_ValidateAll.sh GL 440/ .\_ValidateAll.sh GL 540/ .\_ValidateAll.sh GL 710/

Also cd can access the directory as follows

cd .\\_ValidateAll.sh\ GL\ 190/

Best Answer

If the only issue is that the directories are hidden, you can just remove the . from the beginning of their name to make them unhidden. For example, using perl-rename (called rename on Ubuntu):

rename 's/^\.//' '.\_Validate'*

Or, with just shell tools:

for dir in '.\_Validate'*; do echo mv "$dir" "${dir//.}"; done

Bot of these leave you with horrible directory names though, with spaces and slashes and other unsavory things. Since you're renaming, you may as well rename to something sane:

rename 's/^\.\\//; s/\s+/_/g' '.\_Validate'*

That will result in:

$ ls -d _*
_ValidateAll.sh_GL_100  _ValidateAll.sh_GL_107  _ValidateAll.sh_GL_114
_ValidateAll.sh_GL_101  _ValidateAll.sh_GL_108  _ValidateAll.sh_GL_115
_ValidateAll.sh_GL_102  _ValidateAll.sh_GL_109  _ValidateAll.sh_GL_116
_ValidateAll.sh_GL_103  _ValidateAll.sh_GL_110  _ValidateAll.sh_GL_117
_ValidateAll.sh_GL_104  _ValidateAll.sh_GL_111  _ValidateAll.sh_GL_118
_ValidateAll.sh_GL_105  _ValidateAll.sh_GL_112  _ValidateAll.sh_GL_119
_ValidateAll.sh_GL_106  _ValidateAll.sh_GL_113  _ValidateAll.sh_GL_120

IMPORTANT: note that I am not checking for file name collision. If you rename one of these to something that already exists, then you will overwrite the existing file.

Related Question