Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename an image file from MF Cobol

Status
Not open for further replies.

bhl

IS-IT--Management
Aug 22, 2001
27
US
I have a situation where I need to create a catalog of items that I sell. I have a key field in a record that refers to an image file. I need to renumber the key field and in turn rename the image. I can do the MF COBOL program to rename the key field but is there a way from the COBOL program to rename the image file.

An example -

Key field is "1" the image is "1.mpg".

I want to rename the key field "3" and rename the image "3.mpg".

Any help would be appreciated.
 
WORKING-STORAGE SECTION.

<Level> OLD-FILENAME PIC X(...).
<Level> NEW-FILENAME PIC X(...).

PROCEDURE DIVISION.
<Assuming OLD-FILENAME AND NEW-FILENAME are filled in correctly>
CALL &quot;CBL_RENAME_FILE&quot; USING OLD-FILENAME NEW-FILENAME.
IF RETURN-CODE = 0 *> Rename successfull
...
ELSE *> Rename unsuccesfull
...


Marcel
 
bhl -

Marcel's approach looks OK for AcuCOBOL and perhaps other dialects. I assume, because of the file extensions, you're working on Windows. Almost any Windows COBOL should allow access to ActiveX objects. The Scripting ActiveX control from the Windows Scripting Host allows a bunch of very simple, nice file manipulations using the FileScriptingObject. Of course, one might also simply CALL SYSTEM &quot;REN ...&quot; depending on what your COBOL supports.

Regards.

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top