Computing.Net > Forums > Programming > Capture XCOPY pathway number of characters?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Capture XCOPY pathway number of characters?

Reply to Message Icon

Name: scrfix
Date: May 3, 2009 at 17:30:26 Pacific
OS: Windows XP and Vista
CPU/Ram: 4 Gigabytes
Product: Any pc / Any model
Subcategory: Batch
Comment:

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:
Either
1. Automatically truncates that document being copied.
OR
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.

Thanks,

Wayne
Computer Repair



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: May 3, 2009 at 21:24:53 Pacific
Reply:

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.

M2


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Capture XCOPY pathway number of characters?

count # of characters in file + EOF www.computing.net/answers/programming/count-of-characters-in-file-eof/4457.html

Capture a telephone number www.computing.net/answers/programming/capture-a-telephone-number/2611.html

Count number of files in zip archive www.computing.net/answers/programming/count-number-of-files-in-zip-archive/20254.html