Computing.Net > Forums > Disk Operating System > DOS file rename

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.

DOS file rename

Reply to Message Icon

Name: jrock
Date: August 3, 2002 at 02:05:19 Pacific
Comment:

I have a ton of files that i'm using for a client's website. they're named v6_image_something.gif.
I've changed my PHP script to look for v6.image.something.gif
Is there an easy way to remove ALL underscores and replace with dots (.) using one command? (they're all in the same dir)



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: August 3, 2002 at 13:08:18 Pacific
Reply:

I can't think of a single internal command to do that directly. However, it's quite possible if you use a batch file.

This batch script will do it:

===== BATCH SCRIPT BEGIN =====
@echo off
if "%1"=="GoTo:" %1%2 (Subroutine handler)
echo eE3 2E BF 00 01 89 FE 80 3C 5F 75 03 BE E3 00 A4 E2> %TEMP%.\T1.DAT
echo eF3 F3 89 F9 81 E9 FA 00 53 45 54 20 46 3D>> %TEMP%.\T1.DAT
echo g=E4 FA>> %TEMP%.\T1.DAT
echo wFA>> %TEMP%.\T1.DAT
echo q>> %TEMP%.\T1.DAT
for %%? in (*.jpg) do call %0 GoTo: ren %%?
for %%? in (T1.DAT T2.BAT) do del %TEMP%.\%%?
set F=
goto eof
:ren
if not "%4"=="" goto eof
echo %3> %TEMP%.\T2.BAT
DEBUG %TEMP%.\T2.BAT < %TEMP%.\T1.DAT > nul
call %TEMP%.\T2.BAT

:: To activate script, take out 'echo.{demo}'
:: from next line
echo.{demo}REN %3 %F%

:eof
===== BATCH SCRIPT END =====

Watch out for line wrapping!

Just copy and paste the batch script's contents to a file, save it with .bat extention and run it. The script is de-activated. Run it and see the output, it will show you if the script works or not. If it seems OK, then activate the script (read commented lines to do so).

This batch script will ignore filenames with the following characters:

, ; [space] =

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 2
Name: john
Date: August 3, 2002 at 13:09:41 Pacific
Reply:

Well use the command:

rename v6_image_something.gif v6.image.something.gif


that should do it

JOhn


0

Response Number 3
Name: Secret_Doom
Date: August 3, 2002 at 14:18:45 Pacific
Reply:

John: It's obvious that jrock doesn't want to rename a single file, but a hole bunch of them, following a certain criterion.

> I have a ton of files that i'm using for
> a client's website. they're named
> v6_image_something.gif.

That name surely looks like a generic filename, don't you think?

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Response Number 4
Name: Secret_Doom
Date: August 3, 2002 at 22:12:57 Pacific
Reply:

That script wasn't tested under Win9x, only under WinXP. I've now tested it on Win98 and discovered that it will screw long file names.

I've made the proper changes on the batch script, and now it works ok on both Win98 and WinXP (and so it should work on other NT systems):

===== BATCH SCRIPT BEGIN =====
@echo off
if "%1"=="GoTo:" %1%2 (Subroutine handler)

echo e00 2E BF 00 01 89 FE 80 3C 5F 75 03 BE> %TEMP%.\T1.DAT
echo e0C 00 00 A4 E2 F3 89 F9 81 E9 00 01>> %TEMP%.\T1.DAT
echo g=0 17>> %TEMP%.\T1.DAT
echo w>> %TEMP%.\T1.DAT
echo q>> %TEMP%.\T1.DAT

if "%OS%"=="Windows_NT" goto winNT

echo @PROMPT call %0 GoTo: ren > %TEMP%.\T2.BAT
set DIRCM_=%DIRCMD%
set DIRCMD=
dir/b *.jpg >> %TEMP%.\T2.BAT
set DIRCMD=%DIRCM_%
set DIRCM_=
echo @EXIT>> %TEMP%.\T2.BAT
%COMSPEC% NUL/C %0 GoTo: prefix
for %%? in (call del) do %%? %TEMP%.\T3.BAT
goto finish

:winNT
for %%? in (*.jpg) do call %0 GoTo: ren %%?

:finish
for %%? in (T1.DAT T2.BAT) do del %TEMP%.\%%?
set F=
goto eof

:prefix
%COMSPEC% /C %TEMP%.\T2.BAT > %TEMP%.\T3.BAT
goto eof

:ren
if not "%4"=="" goto eof
echo SET F=%3> %TEMP%.\T2.BAT
DEBUG %TEMP%.\T2.BAT < %TEMP%.\T1.DAT > nul
call %TEMP%.\T2.BAT

:: To activate script, take out 'echo.{demo}'
:: from next line
echo.{demo}REN %3 %F%

:eof
===== BATCH SCRIPT END =====

Watch out for line wrapping!

The script is de-activated. Run it and see the output, it will show you if the script works or not. If it seems OK, then activate the script (read commented lines to do so).

I apologize for my mistake.

PS: If you're on a NT system, a simpler batch script could be used (but this one will do it!)

-- Leonardo Pignataro - Secret_Doom --

secret_doom@hotmail.com
www.batch.hpg.com.br


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


to implement multitasking... Toshiba T3100



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: DOS file rename

DOS file Rename www.computing.net/answers/dos/dos-file-rename/9396.html

DOS Files www.computing.net/answers/dos/dos-files/15718.html

Corrupting DOS files www.computing.net/answers/dos/corrupting-dos-files/4230.html