Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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)

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

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

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.DATif "%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

![]() |
to implement multitasking...
|
Toshiba T3100
|

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