Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am looking for a way to convert a directory of files to the DOS 8.3 length. I have tried different commands, and can manually do it using winfile.exe, but I need a more direct way, like a batch file. Any ideas?

The following batch script will rename all the files from the folder %TARGET% to 8.3 format:
@echo off
:: Set directory where to rename files below
set TARGET=C:\AnyFolder:: To include hidden and system files on the
:: rename process, add the string '/a' right
:: after the string 'dir' on next line
dir/b/z %TARGET%.\*.*> %temp%.\T1.BAT
echo e100'SET %%1='> %TEMP%\T3.DAT
for %%? in (rcx 7 w q) do echo %%?>> %TEMP%.\T3.DAT
type nul> %TEMP%.\T2.DAT
DEBUG %TEMP%.\T2.DAT < %TEMP%.\T3.DAT > nul:loop
copy/y %TEMP%.\T2.DAT+%TEMP%.\T1.BAT %TEMP%.\T3.DAT > nul
FIND "SET %%1=" < %TEMP%.\T3.DAT > %TEMP%.\T1.BAT
call %TEMP%.\T1.BAT FILE
if "%FILE%"=="" goto loopend
ren "%TARGET%.\%FILE%" "%FILE%"
FIND/v "SET %%1=" < %TEMP%.\T3.DAT > %TEMP%.\T1.BAT
goto loop:loopend
for %%? in (T1.BAT T2.DAT T3.DAT) do del %TEMP%.\%%?
set TARGET=
:eofThat script is compatible with Win9x only. It will not rename hidden nor system files. There's an instruction on the source saying how to include such files on the rename process.
You didn't mention the script should also rename the files from subdirectories, so it doesn't. However, that's also possible (though the script will be different).
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br_____________________________________________________________

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |