os.link & NTFS 5

yaipa yaipa at aol.com
Sat Dec 28 00:13:44 EST 2002


I pulled this off of the Usoft website, enjoy. 'Scuse the VB. 


' Hardlinks.vbs
' Demonstrates hard links on NTFS volumes 
' --------------------------------------------------------

Option Explicit

' Some constants
Const L_NoHardLinkCreated = "Unable to create hard link"
Const L_EnterTarget = "Enter the file name to hard-link to"
Const L_HardLinks = "Creating hard link"
Const L_EnterHardLink = "Name of the hard link you want to create"
Const L_CannotCreate = "Make sure that both files are on the same
volume and the volume is NTFS"
Const L_NotExist = "Sorry, the file doesn't exist"
Const L_SameName = "Target file and hard link cannot have the same
name"

' Determine the existing file to (hard) link to
dim sTargetFile 
if WScript.Arguments.Count >0 then
   sTargetFile = WScript.Arguments(0)
else
   sTargetFile = InputBox(L_EnterTarget, L_HardLinks, "")
   if sTargetFile = "" then WScript.Quit
end if

' Does the file exist?
dim fso
set fso = CreateObject("Scripting.FileSystemObject")   
if Not fso.FileExists(sTargetFile) then
   MsgBox L_NotExist
   WScript.Quit
end if

' Main loop
while true
   QueryForHardLink sTargetFile
wend


' Close up
WScript.Quit





"DP" <pennedinil at excite.com> wrote in message news:<auf11l$ibo16 at news.emirates.net.ae>...
> [Not sure if my previous post made it, so reposting]
> 
> I'm looking for the equivalent of os.link and os.symlink for Python/WinXP
> (i.e., NTFS 5). These functions seem to be available only on Python/UNIX.
> They're also available on Python/Cygwin.I haven't found anything similar to
> this for Win32 platforms.
> 
> I'm copying source files to directories named as
> TARGET\data_val_a\data_val_b\* as well as TARGET\data_val_b\data_val_a\*.
> data_val_{a|b} are values parsed from the files being copied. I'd prefer to
> save the two copies of files as links to preserve disk space and ease file
> management.
> 
> I also need a means of manipulating file permissions and properties from
> within Python. What's the best way of going about this? Again, I just don't
> know enough.
> 
> Another application is font management. With Windows, Cygwin, XFree,
> ghostscript (Cygwin & Win32), Adobe products, GNUWin32 tools, MikTex, Latex
> for Cygwin, etc. all creating their own font directories, managing the font
> files is turning out to be extremely difficult. I'd rather have these saved
> as a single copy linked into the other directories.
> 
> Obviously there are other applications.
> 
> Thanks in advance.
> 
> Dinil.
> 
> If possible, please forward a copy of responses to pennedinil @ excite.com.
> I don't have access to a news server, so I'm only able to view responses
> from 6 to 10 hours after they're posted.



More information about the Python-list mailing list