mysticfalls
mysticfalls

Reputation: 455

Remove spaces on filename windows

Can someone help me to remove spaces in a filename of windows.

Example:

   ABCD001 _V01.DOC >>>> ABCD001_V01.DOC
   ABCD002 _V01.DOC >>>> ABCD002_V01.DOC

Thank you.

Upvotes: 0

Views: 3060

Answers (2)

Lloyd
Lloyd

Reputation: 8396

Using renamer:

$ renamer --find "/\s/g" --dry-run *

This will remove all whitespace from filenames in the current directory. Once you're happy the output looks correct, remove the --dry-run flag.

Upvotes: 1

foxidrive
foxidrive

Reputation: 41234

Test this on some sample files first:

@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir /b /a-d') do (
   set "line=%%~nxa"
   ren "%%a" "!line: =!"
)

Upvotes: 0

Related Questions