vbscript - Duplicating a complex folder structure with only shortcuts -


There are two shared drives, one of these is a very complex folder structure. I would like to repeat the entire folder structure to share 1 to share 2. But I do not want to create a duplicate file, but instead I want to present a shortcut or symbolic link in the other part. I tried to do this with existing tools like Robocopy and Emklink and failed to get results. Any idea to solve this issue has been highly appreciated.

You have to work it under the Filesystemobject folder structure, If the folder is present in the destination, do nothing and create a shortcut for all the hosting folders files in that folder otherwise create a folder and create a shortcut for the hosting files anyway.

Dofolder This is like the following by all subfolders: GetFN function only collects file names of all files in the hosting folder. That if the file name contains some time

it was a fun program to write, thanks.

FolderShadows.vbs

  dim fosco, hostfolder, destfolder 'host folder - folder should be present. HostFolder = "C: \ from \ Folder" Destination Folder - The folder must exist. DestFolder = 'D: \ "folder for FSO set = CreateObject (" Scripting.FileSystemObject ") DoFolder fso.GetFolder (HostFolder) are sub DoFolder (folder) dim subfolders (fso.GetAbsolutePathName (folder), fso.folderexists HostFolder, DestFolder) = false then fso.createfolder (Replace (fso.GetAbsolutePathName (folder), HostFolder, DestFolder)) then Folder.SubFolders DoFolder subfolders for each file in each subfolder Folder.Files Dim file name in the next slow file For, if shortcut (fso.fileexists (change (fso.GetAbsolutePathName (folder), HostFolder, DestFolder) & amp; "\" & GetFN (File.Name) & amp; .lnk ") false =) then rename the file name = (fso.GetAbsolutePathName (folder), hostfolder, destfolder) & amp;" \ "& amp; GetFN (File.Name) & amp;" .lnk "shortcut = set Set the object ("WScript.Shell"). CreateShortcut (FileName) shortcut. Description = "shortcut to" & file name. Shortcut. Target = phso.getAbsolutePathName (folder) & amp; "\" & Amp; File Name shortcut.Save end then the next End Sub function GetFN (filename) dim result, I get the result = filename = I = InStrRev (file name, ".") Then (i & gt; 0) Then the result = middle (filename, 1, i - 1) end if GetFN = the result terminator function   

note : this script is on automatic schedule Because it is designed to auto-update shortcuts and folders if new files / folders are found

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -