FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour C贸mo cambiar extensi贸n a un archivo? (SOLUCIONADO)
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
C贸mo cambiar extensi贸n a un archivo? (SOLUCIONADO)
Posted: Sat Oct 19, 2024 08:29 PM

Amigos del foro:

Existe alguna funci贸n para cambiar la extensi贸n a un archivo?

Algo As铆

CambiaNombre(MiArchivo.Xlsx,MiArchivo.Txt)

O tengo que hacerlo con un BAT?

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: C贸mo cambiar extensi贸n a un archivo?
Posted: Sat Oct 19, 2024 09:19 PM
Code (fw): Select all Collapse
RENAME <cOldFile> TO <cNewFile>
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: C贸mo cambiar extensi贸n a un archivo?
Posted: Sun Oct 20, 2024 12:47 AM
cFile := hb_FNameExtSet( cFullPath, cExt ) // Sets a new extension of a file, returns new full path.
cFile := hb_FNameExtSetDef( cFullPath, cExt ) // Sets a new extension of a file in case if it is absent, returns new full path.
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1710
Joined: Tue Oct 28, 2008 06:26 PM
Re: C贸mo cambiar extensi贸n a un archivo?
Posted: Sun Oct 20, 2024 11:33 AM
Armando

Intenta as铆
Code (fw): Select all Collapse
DBRENAME("C:\MiArchivo.Xlsx","MiArchivo.Txt")
Saludos,



Adhemar C.
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: C贸mo cambiar extensi贸n a un archivo?
Posted: Sun Oct 20, 2024 12:35 PM
acuellar wrote:Armando

Intenta as铆
Code (fw): Select all Collapse
DBRENAME("C:\MiArchivo.Xlsx","MiArchivo.Txt")
Excelente Adhemar, este comando, no lo conoc铆a. Otro m谩s de la colecci贸n. jajajaja.
Code (fw): Select all Collapse
// C:\FWH\SAMPLES\RENAMEAD.PRG

#include "FiveWin.ch"

FUNCTION Main()

聽 聽IF FILE( "C:\TMP\SILVIA.TXT" )

聽 聽 聽 DBRENAME( "C:\TMP\SILVIA.TXT", "ADHEMAR.TXT" )

聽 聽ELSE

聽 聽 聽 MsgInfo( "Archivo Inexistente", "Archivo Inexistente" )

聽 聽ENDIF

RETURN NIL
Reagrds, saludos.
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: C贸mo cambiar extensi贸n a un archivo?
Posted: Sun Oct 20, 2024 04:19 PM

Enrico, Crist贸bal, Adhemar, Karinha:

Gracias a todos !

Wow, tengo varias alternativas, Esto es lo hermoso de este foro.

voy a probar y aviso.

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: C贸mo cambiar extensi贸n a un archivo?
Posted: Sun Oct 20, 2024 06:56 PM

Amigos:

Comento los resultados

Con la sugerencia de Enrico, no me funcion贸, tal vez no lo hice bien, gracias

Con la sugerencia de Crist贸bal

? hb_FNameExtSet( oVar:FIL, "Txt")

Me muestra el archivo con la nueva extensi贸n pero no cambia el archivo original

tal parece que deja una copia con la nueva extensi贸n

Con la sugerencia de Adhemar

DBRENAME(oVar:FIL,"MiArchivo.Txt")

Funcion贸 como yo neceistaba, cambiar el nombre y extensi贸n al archivo original.

Muchas gracias a todos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: C贸mo cambiar extensi贸n a un archivo?
Posted: Sun Oct 20, 2024 07:08 PM
Armando wrote:Con la sugerencia de Enrico, no me funcion贸,
The command RENAME is the only standard rename command since the Clipper days. This is a working sample:
Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

聽 聽 MEMOWRIT( "MYTEST.ABC", "This is a test" )

聽 聽 RENAME MYTEST.ABC TO MYTEST.TXT

聽 聽 RETURN NIL
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: C贸mo cambiar extensi贸n a un archivo?
Posted: Mon Oct 21, 2024 12:38 AM
As铆:
Code (fw): Select all Collapse
聽 聽local cFile 聽:= "D:\fwh\FwhTeam\samples\test.txt"
聽 聽? FRename( cFile, hb_FNameExtSet( cFile, ".src") )
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noci贸n del tiempo

El secreto de la felicidad no est谩 en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: C贸mo cambiar extensi贸n a un archivo? (SOLUCIONADO)
Posted: Mon Oct 28, 2024 07:36 AM
Code (fw): Select all Collapse
cName := "MyFile.xlsx"
if FRename( cName, cFieSetExt( cName, "txt" ) ) != 0
聽 聽? "Rename Error"
endif
cFileSetExt( cFile, cExt ) is one of the many filename functions of FWH, which existed from the inception of FWH.
Re: \fwh\source\function\filename.prg
Regards



G. N. Rao.

Hyderabad, India
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: C贸mo cambiar extensi贸n a un archivo? (SOLUCIONADO)
Posted: Mon Oct 28, 2024 04:20 PM

Mr. Rao:

Thanks, I will try your advice

Regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero

Continue the discussion