Solved Batch folder replace/rename .dat

December 2, 2014 at 05:06:01
Specs: Windows 7, 4gb
Hi Folks,

Great help so far. What im trying to do is to replace "." and "_" with a space on FOLDERS and not files. I have got the batch file to work for files below but could do with a little extra help to rename the folders.

@echo off
setlocal enabledelayedexpansion
for %%j in (*.*) do (
set filename=%%~nj
set filename=!filename:_= !
set filename=!filename:.= !
if not "!filename!"=="%%~nj" ren "%%j" "!filename!%%~xj"

Many thanks

See More: Batch folder replace/rename .dat

Report •

December 2, 2014 at 20:19:17
Not tested. I haven't used this variation much:
for /D %%j in (*.*) do (

(see: for /?)

Report •

December 10, 2014 at 05:42:10
✔ Best Answer
thanks for the response, but i got it sorted.

FOR /D /R %%i IN (*) DO (
SET "n=%%~nxi"
REN "%%i" "!n:_= !"
REN "%%i" "!n:.= !"

Report •

Related Solutions

Ask Question