Page 1 of 1
script request - short DOS names
Posted: 26 Apr 2017 20:02
by SkyFrontier
Do anyone there have a script which
-delivers 8.3 DOS format for selected item(s) name(s)
-delivers 8.3 DOS format for selected item(s) full path(s)?
Reason:
Item Short Path/Name(s) (plus correspondent CKS command ID) is failing on win8 but works on a win7 virtualized machine (tested on current XY version plus an old 11.70). Rather than relying on a possible bug fix (possible win fault?), I'd like to have the option to have this function working flawlessly anywhere, even on such older version* which I need to stick together to.
Thanks in advance!
___
* ie, runret is not an option here, please.
Re: script request - short DOS names
Posted: 26 Apr 2017 23:07
by highend
Are you sure that 8.3 filenames are enabled on that Win 8 system?
from a command prompt
And this could be scripted (some rules are here:
https://en.wikipedia.org/wiki/8.3_filen ... t_filename)
but I stumbled upon an example that makes no sense to me:
http://answers.google.com/answers/threa ... 22710.html
Code: Select all
02/10/2004 11:52 <DIR> REGIST~2 RegisteredPackages
31/12/2004 02:38 <DIR> REGIST~1 Registration
Can't explain why the first item has the ~2 for it's short name...
Apart from that as an idea how to create it:
Code: Select all
// Convert long to short name
$item = <curitem>;
$base = gpc($item, "base");
$ext = gpc($item, "ext");
// Get the base name if it's less or equal to 8 chars or the condensed name
// with 6 chars, all spaces and dots removed
$short = (strlen($base) <= 8) ? $base : substr(regexreplace($base, "[ .]*"), 0, 6);
if ($short == $base) { $shortFinal = $short; }
else {
// List all items of the same type (extension | folder)
$type = (exists($item) == 1) ? "f" : "d";
$query = ($type == "f") ? "*." . gpc($item, "ext") . " /nf" : "/nd";
$sameType = quicksearch($query);
$index = gettokenindex($item, $sameType, <crlf>, "i");
// We need only the 1 - $index items, remove all following ones
$sameType = gettoken($sameType, $index, <crlf>, , 1);
// Now find all items that match our short name "enriched" with any amount
// of spaces or dots after each character
$pattern = regexreplace($short, "(.)", "$1[ .]*");
$matches = regexmatches($sameType, $pattern, <crlf>);
// The last index must be our new suffix "~<index>"...
$shortFinal = recase($short . "~" . gettoken($matches, "count", <crlf>) . (($type == "f") ? ".$ext" : ""), "U");
}
text $shortFinal;
For full paths it's basically the same with a loop over all "\" separated tokens (excluding drive letter tokens / network paths)...
Re: script request - short DOS names
Posted: 02 May 2017 16:42
by SkyFrontier
highend wrote:
Can't explain why the first item has the ~2 for it's short name...
It's stuff like that that prevented me from taking my efforts seriously...
Another thing (which should be checked against that win7 'real world' scenario, assuming XY properly does the job when it works), which sounds pretty dumb as I don't see stuff like that in years now:
REGIST~1...REGIST~999 or REGI~999?
Your script deals with that?
Thanks for the support. Yet again.
Re: script request - short DOS names
Posted: 02 May 2017 18:09
by highend
Nope but it wouldn't be difficult to implement that. Just check how these files are generated with 0-99, 100-999, etc...