Capture XCOPY pathway number of characters?

Any pc / Any model
May 3, 2009 at 17:30:26
Specs: Windows XP and Vista, 4 Gigabytes
I am running into an issue that is very common across the Internet with XCOPY.

Please Note:
I cannot utilize XXCOPY or Robocopy as a work-a-round much as I would like to.

The Issue:
"Insufficient Memory" Error
This memory error is not due to physical memory on the computer. This is due to character limits for the pathway in XCOPY. No more than 254 characters in the source or destination pathway.

Since Windows XP 32 Bit (Unsure about Vista or 64 Bit OS's) also has this 254 Character Limitation in its pathways on the Operating System this error will more than likely come up 90% of the time with the destination we are copying to such as my case.

I would like to create function that gets called, counts the number of characters in the pathway preferably before or at the time the xcopy command is being executed. If it finds one over 230 characters then:
1. Automatically truncates that document being copied.
2. Automatically renames the destination directory %folder% to a shorter name.

Is this possible?
Can someone help me accomplish this?

Any help would be greatly appreciated.


Computer Repair

See More: Capture XCOPY pathway number of characters?

Report •

May 3, 2009 at 21:24:53
Here's how you get the path length. If you're going to truncate the directory structure may as well do it just once and have it over with. You could also make a script using plain old COPY.

:: get the lengthof a path
:: pathleng Mon 04-05-2009 11:00:31.03

@echo off & setLocal EnableDelayedExpansion

set src=C:\Documents and Settings\Administrator\Application Data
echo !src! > %TEMP%\#

for %%a in (%TEMP%\#) do (
set /a FS=%%~Za-3
echo src size is !FS!
if !FS! lss 230 echo shorter

If at first you don't succeed, you're about average.


Report •
Related Solutions

Ask Question