Computing.Net > Forums > Disk Operating System > Convert file name to 8.3 length

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Convert file name to 8.3 length

Reply to Message Icon

Name: fmason96
Date: March 12, 2003 at 08:05:58 Pacific
OS: Windows 98
CPU/Ram: pIII/256
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: March 12, 2003 at 16:02:56 Pacific
Reply:

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=
:eof

That 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

_____________________________________________________________


0
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Convert file name to 8.3 length

convert 8.3 to longnames www.computing.net/answers/dos/convert-83-to-longnames/11256.html

Rename the file name to %Date%-1 www.computing.net/answers/dos/rename-the-file-name-to-date1/14085.html

How make file names longer in DOS? www.computing.net/answers/dos/how-make-file-names-longer-in-dos/9360.html