Recursively rename all files whose name starts with a dash

Using find and rename:

find . -iname '-*' -execdir rename -n 's:./-:./:' {} +

find . -iname '-*' matches all filenames beginning with a -, and then -execdir ... {} + runs the command with those filenames as arguments, after cding to the directory containing the files. This means that the command arguments always has filenames of the form ./-foo. Then it's easy to just match the - after the ./ in a regex.


I guess this should work as well

for i in $(find . -iname '-*') ; do mv $i $(echo $i | sed -e "s/-//"); done