"AndyHancock" <andymhancock@gmail.com> wrote:
> I used a unix utility (cygwin's tar) to copy a file
> tree from a hard drive to a stick. One of the things
> I learned was that file links/shortcuts contain a
> full path to their target rather than a relative path.
> These are the files created by "Paste shortcut" or
> Shift-Ctrl-Drag. After the file tree is copied to the
> stick, all such file links no longer point to valid
> destinations.
Question: What good are links to files if you remove
them from the computer that contains the files they
link to? Are the files in question programs that
are on both the source and destination machines, or
something like that?
> I used a text editor like vim to look at the file
> shortcuts, and I can see the full path to the target.
I just went to folder "D
Library" on my computer,
right-click-dragged file "Bike-Shops.txt" to "D
",
selected "create shortcut". I renamed the shortcut
to "Aardvark" (no extention). But yet, it DOES have
an extention, because when I look at it with a "dir"
command from a command prompt, it's actual name is
"Aardvark.lnk". On opening it with "edit", it
contains binary (non-text) gibberish, interspersed
with characters from the absolute path:
"D
Library\Bike-Shop.txt". I can't see how you
could edit that; it's a binary file.
Attempting to edit "D
Aardvark.lnk" GVim resulted
in GVim opening "D
Library\Bike-Shops.txt" instead.
Are you *sure* you were able to edit a link in Vim?
(That is, are you sure that what you edited wasn't
the TARGET rather than the LINK?)
> Is there a hopefully simple way to convert these
> paths to relative paths? I guess that would also
> depend on whether file shortcuts can even point to
> targets using relative paths. Moreover, is there
> a hopefully simple way to traverse a file tree and
> convert all file shortcuts to use relative paths?
To the best of my knowledge, there is no such thing
as a "relative-path shortcut" in any Microsoft
Windows version.
If you think about it, what you are trying to do
makes little sense. Firstly, "relative path" links
would work only with link on same drive as target,
whereas in reality, a link on drive D: often refers
to a file on drive E: or C: or X:. Secondly, people
move shortcuts around all the time; if shortcuts had
link info relative to their own location, that info
would be invalidated the moment the shortcut was moved.
> Failing that, is there a simple way to replace all
> file shortcuts with their target files throughout
> a subtree in the file hierarchy?
I don't know a simple way to replace a bunch of
shortcuts with their targets, no. I suppose
you could find or write a program, or have
someone write one for you. (I could write it
for you, but I don't work for free.)
But more importantly, why would you want to do that?
Be aware that if the targets are programs
(exe files), if you move them to new locations,
they probably won't work, because they'll be
looking for files they need (such as dll files)
and not finding them.
Also be aware that replacing shorcuts with
targets can increase space used by several orders
of magnitude. (Consider a link to an mp3 file.
The link takes 1KB. The target takes 10000KB.)
Instead of trying to replace the shortcuts with
their targets (dubious idea, in my opinion),
why not look for a way to simply correct the
shortcuts so they point to the right location?
Or MUCH better, look for a way to generate
fresh shortcuts on the destination computer,
rather than trying to copy shortcuts from
another computer which may not even have the
same collection of targets?
When I need to make shortcuts to things, I right-click
my desktop, select "Create New Shortcut", navigate to
the target, specify a name for the shortcut, hit "OK".
Then I move the shortcut to its final location (usually
one of my toolbars).
Perhaps if you say more specifically what you
are trying to do, it would help folks here to
give you better advice.
--
Cheers,
Robbie Hatley
lonewolf at well dot com
www dot well dot com slant tilde lonewolf slant