在文件夹中递归创建快捷方式(XP)

时间:2010-10-22 14:49:02

标签: windows scripting windows-scripting

1>

我在文件夹结构中有文件夹。

2 - ; 我想以递归方式创建每个文件的快捷方式。

快捷方式必须放在相同的命名文件夹中,它位于源头。

3>

摘要:相同的文件夹结构......只是代替文件的快捷方式

任何想法都将受到赞赏。

2 个答案:

答案 0 :(得分:0)

您是否需要有关递归的帮助,或者只是关于如何完成此操作的一些简单想法?我不会写它,但你可以使用recursive batch file初始命令看起来像:

batchFile.bat "C:\OriginalLocation" "C:\CopyToLocation"

我认为唯一的问题是你需要一个外部程序来创建快捷方式(一个快速的谷歌搜索出现了一些)。您可以使用VBScript执行相同的操作,而无需外部快捷方式创建程序(再次,谷歌搜索提出了几种方法)。

答案 1 :(得分:0)

这是你可以尝试的vbscript

Set objFS = CreateObject( "Scripting.FileSystemObject" )
Set oWS = WScript.CreateObject("WScript.Shell") 
strFolder=WScript.Arguments(0)
Set objFolder = objFS.GetFolder(strFolder)
Go (objFolder)
Sub Go(objDIR)
  If objDIR <> "\System Volume Information" Then
    For Each eFolder in objDIR.SubFolders
        Go eFolder
    Next
    For Each strFile In objDIR.Files
        shortcut = objFS.BuildPath(objFS.GetParentFolderName(strFile), objFS.GetBaseName(strFile)&".lnk")
        Set oLink = oWS.CreateShortcut(shortCut) 
        oLink.TargetPath = strFile.Path
        oLink.WorkingDirectory = objFS.GetParentFolderName(strFile)
        oLink.Save
        Set oLink=Nothing
    Next
  End If 
End Sub 

用法:

C:\test> cscript //nologo mycreateshortcutscript.vb C:\test