I'm trying to run through folders and subfolders (only, no files can be altered) in a given directory which have leading underscores and remove those leading underscores. I'm planning on accomplishing this with a simple shell script:
for folder in ./_* do
mv "$folder" "${folder:1}"
done
The above script doesn't work yet to specification for two reasons which I'm trying to correct here:
- one, the "./_*" does not work like it should, either throwing an error (./_*: No such file or directory
) or selecting folders which do not have leading underscores too.
- two, it does not specify folders only...is there an option for the mv
command which can do that?
Thanks
To find all folders starting with underscore use this
find
:And to remove
_
use: