Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

Thanks

share|improve this question

migrated from stackoverflow.com Jun 7 '13 at 20:33

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

add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

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