i got some folder names like name_surname in a folder and i wanna make them all name-surname, as there are like thousands of them i am not able to rename one by one, is there a command i can do this simplier? thanks
There is no command to do that automatically. I suck with shell script, so I do things like that using php instead. <?php $dir = "/home/user/domain.ext/folder/"; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { $files[] = $file; } sort($files); foreach($files AS $file) { $starts_with = substr($file, 0, 1); if (($starts_with != ".")) { // . and .. are directives, other . files probably shouldn't be touched anyways $newname = str_replace("_", "-", $file); rename($dir . $file, $dir . $newname); } } closedir($dh); } } ?> PHP: Something like that will probably do the trick for you; though, if the files you're looking to change are folders, then I don't know for sure.
I have shell script: create rename.sh #!/bin/sh for name in $(find . -type d -print | sed 's/_/____/g') do if [ $name != "." ] ; then oldname="$(echo $name | sed 's/____/_/g')" newname="$(echo $name | sed 's/____/-/g')" if [ "$oldname" != "$newname" ] ; then echo "renaming \"$oldname\" to $newname" mv "$oldname" "$newname" fi fi done save it and chmod to 755. Ask your host to execute the shell script in the directory with ./rename.sh