Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folder which contains 4 sub folders and in each of these 4 folders there are more folders that contain images.

I need to replace all the spaces in the image names with hyphens e.g.

blue magazine.jpg would become blue-magazine.jpg

Is there any way I can do this using a batch file / some free software / via command prompt or any other ways?


share|improve this question

migrated from Jun 7 '13 at 20:33

This question came from our site for professional and enthusiast programmers.

Try using for.

for /f "tokens=1,2,3" %i in ('dir /b /s *.jpg') DO move "%i %j" "%i-%j"

This would replace spaces with hyphens in .jpg files in the current directory and subdirectories.

share|improve this answer

I do all my scripting work using linux bash. This way knowing one scripting language is enough. To have it on Windows, install MSYS. Then use commands find with -exec clause and mv.

I install MSYS also in Windows server environments, without problems. Actually the installation process is not necessary. It runs simply after copying the files.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.