[<<]Message[>>]    [<<]Author[>>]    [<<]Subject[>>]    [<<]Thread[>>]

Number : 8683 Date : 2004-09-08 Author : Garry Deane Subject : Re: copy a specific directory and its contents Size(KB) : 2
--- In xxcopy@yahoogroups.com, "jayahr00" wrote: > As I noted above (in the misplaced response), your suggestion > worked fine in testing. When I put it into production, I came > across a slight wrinkle. The source parameter you suggested, > \*%1\ for selecting mydocu~1 etc, works great in selecting > directories with namelength=8 (as an aside, it works fine > whether \*%1\ or \%1*\ is used). When a dirname of less > than 8 is used, i.e. \*dir1\, this technique selects all > directories whose name contains dir1, i.e. xxdir1 in addition > to dir1. Any suggestions on how I can force a comparison at > pos1 only, or of any padding character I can use that > would select dir1 only and not xxdir1. Thanks again for > your help. Hmm, yes. I was was thinking about LFNs and hadn't thought about normal SFNs. The only thing that quickly springs to mind is to check whether the passed directory name includes a ~ character indicating a LFN. Something like: set src=\*%1\ set dst=\backup\ echo %1 | find "~" > nul if errorlevel 1 set src=\%1\ if errorlevel 1 set dst=\backup\%1\ Unfortunately this won't work if you pass a directory path which starts with a SFN but has a LFN later in the path like dir1\longdi~1. This would end up as \*dir1\longdi~1\. It would also fail if you have any directories with ~ in the name which are SFNs e.g. \dir~name\ If this is unsuitable, other than using a utility, I can only think of passing the long file name from your calling batch without quotes then reconstructing the LFN path from the passed parameters e.g. call yourbat.bat Program Files\Common Files :: Yourbat.bat set src=%1 :Parse if "%2"=="" goto done shift set src=%src% %1 goto Parse :Done set dst="\backup\%src%\" set src="\%src%\" Note that this too would fail in the unlikely case of paths with multiple side-by-side spaces. If this is no good either, you'd need to look at whether you can change your parameters in the calling batch to include the * when appropriate. > Jay. P.S. Sorry to address you and burden you with this.. > Since this is a group I thought someone else might jump in > and share the load. No problem. It's just that we're both in similar time zones. Most of the group are fast asleep at the moment. Since I'll be away for a few days, they'll get an free run for a while but you'll have a bigger lag between Q and A. Garry
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.