Skip to main content

Is there a way to use the COBOL File Handling routines with filenames that contain spaces?

I want to use CBL_RENAME_FILE to rename a file from say "TEST-FILE.TXT" to "TEST FILE.TXT" i.e. I want the final file name to include a space.  Is this possible - with this routine or in any other way?

Many thanks,


#CBL_COPY_FILEerror
#netexpress

Is there a way to use the COBOL File Handling routines with filenames that contain spaces?

I want to use CBL_RENAME_FILE to rename a file from say "TEST-FILE.TXT" to "TEST FILE.TXT" i.e. I want the final file name to include a space.  Is this possible - with this routine or in any other way?

Many thanks,


#CBL_COPY_FILEerror
#netexpress

This is possible by quoting the filename, e.g.

MOVE '"TEST FILE.TXT"' TO FILE-NAME


Is there a way to use the COBOL File Handling routines with filenames that contain spaces?

I want to use CBL_RENAME_FILE to rename a file from say "TEST-FILE.TXT" to "TEST FILE.TXT" i.e. I want the final file name to include a space.  Is this possible - with this routine or in any other way?

Many thanks,


#CBL_COPY_FILEerror
#netexpress

Thank you but unfortunately that doesn't work - it prepares the FILE-NAME but as soon as I use "CBL_RENAME_FILE" to rename the file the name gets truncated to "TEST", because the routine uses space delimited names.

However, I have found I can use CALL X"91" to run a DOS command to copy the file.  It's a bit messy, especially as it flashes up a DOS window - but it works.

I was hoping someone would suggest a better way.


Is there a way to use the COBOL File Handling routines with filenames that contain spaces?

I want to use CBL_RENAME_FILE to rename a file from say "TEST-FILE.TXT" to "TEST FILE.TXT" i.e. I want the final file name to include a space.  Is this possible - with this routine or in any other way?

Many thanks,


#CBL_COPY_FILEerror
#netexpress

I am using some of the CBL_Routines within a backup program (CBL_COPY_FILE, CBL_DELETE_FILE, CBL_CHECK_FILE_EXIST). Filenames with spaces are properly handled. But i don't put together the filenames manually. Before i scan the desired directories with X"91" function 69 and use the filenames returned without changes.


Is there a way to use the COBOL File Handling routines with filenames that contain spaces?

I want to use CBL_RENAME_FILE to rename a file from say "TEST-FILE.TXT" to "TEST FILE.TXT" i.e. I want the final file name to include a space.  Is this possible - with this routine or in any other way?

Many thanks,


#CBL_COPY_FILEerror
#netexpress

You are correct about the routine using space delimited names, so my suggestion was missing the ending space of the file name.

It should be then formatted as <single-quote><double-quote>Filename With Spaces<double-quote><space><single-quote>, i.e. '"TEST FILE.TXT" '