views:

810

answers:

6

I've been working on spooling a bat file from a oracle query that would copy contents from one location to another,

Now that command that are getting generated are of lengths that are greater than 255 characters, e.g

C:> copy x y ( where len (x+y) > 255)

As this is throwing an error, is there a work around to manage this kind of situation to increase that command length?

P.S. Some paths+filenames are of length that are larger that 259 characters, to which I found that say there is less to argue

A: 

I don't think so; I'd write that to a file maybe.

Noon Silk
I am using a bat file to execute that command, but it throws an error... "the filename is too long"
81967
+1  A: 

Probably no, sounds like you're hitting the MAX_PATH limitation. See File Names, Paths, and Namespaces on MSDN.

Possible workaround might be to use the short path equivalents, e.g. C:\Progra~1.

According to the the following article Command prompt (Cmd. exe) command-line string limitation,

On computers running Microsoft Windows XP or later, the maximum length of the string that you can use at the command prompt is 8191 characters. On computers running Microsoft Windows 2000 or Windows NT 4.0, the maximum length of the string that you can use at the command prompt is 2047 characters.

Bob
+4  A: 

You could use subst to name the two subdirectories your working from with drive letters. Obviously the are not real, but logical drives then, but you could substantially shorten the paths.

LASTDRIVE=Z
SUBST S: c:\this is a very long path name\source
SUBST T: d:\this is a very long path name\Target
#do whatever you need to, like
copy s:\filename T:\filename
SUBST S: /D
SUBST T: /D

The /D parameter frees the association.

Ralph Rickenbach
Hi Ralph, your solutions is working fine .. thanks.... , but the only issue I have is that anything greater than around 256 characters, the command line is not taking, (I'm using 2000 server), that would have made the solution much simpler.
81967
A: 

You may want to consider using DBMS_FILE_TRANSFER.COPY_FILE instead of creating a bat file. You can avoid using bat files (which are platform dependent) altogether.

Håvard
+1  A: 
  1. SUBST (has already been proposed)
  2. use 8.3 notation (e.g. C:\Progra~1\ - also has been proposed)
  3. Use this syntax (if you run Command prompt in Windows): copy \?\c:\verylongpath\verylongname \?\d:\anotherverylongpath\
DmitryK
A: 

Try using a .cmd file, not a .bat file unless you are using Win95/98/ME. This could solve the entire problem right there.

If that doesn't do it, you can break a command by preceeding a line break with the cmd-escape char ^ or by wrapping the command in parentheses.

brianary