Dynamically create folder structure on UNC share
Dynamically create folder structure on UNC share
(OP)
Hi Everyone,
I am using some code kindly provided by snotmore...
Is there a way to make the above work with a UNC?
I love the way the code dynamically creates the folders if they don't exist and is exactly what I need but it needs to work over the network to a UNC share. I think the \\ at the beginning of a UNC is what's causing this to not work.
Any ideas?
To give a little background, I'm backing up a file located on an RDSH server that resides in the %localappdata% folder. I'm saving this to a specific folder on the network based on the users login name. When the user logs in again, another script using slightly different source and destination folders will copy the data back. Therefore, on the restore, the above works great... just the backup that fails.
I am using some code kindly provided by snotmore...
CODE -->
Call subCreateFolders("C:\test1\test2\test3\") Sub subCreateFolders(strPath) Dim objFileSys Dim strPath, strNewFolder Set objFileSys = CreateObject("Scripting.FileSystemObject") If Right(strPath, 1) <> "\" Then strPath = strPath & "\" End If strNewFolder = "" Do Until strPath = strNewFolder strNewFolder = Left(strPath, InStr(Len(strNewFolder) + 1, strPath, "\")) If objFileSys.FolderExists(strNewFolder) = False Then objFileSys.CreateFolder(strNewFolder) End If Loop End Sub
Is there a way to make the above work with a UNC?
I love the way the code dynamically creates the folders if they don't exist and is exactly what I need but it needs to work over the network to a UNC share. I think the \\ at the beginning of a UNC is what's causing this to not work.
Any ideas?
To give a little background, I'm backing up a file located on an RDSH server that resides in the %localappdata% folder. I'm saving this to a specific folder on the network based on the users login name. When the user logs in again, another script using slightly different source and destination folders will copy the data back. Therefore, on the restore, the above works great... just the backup that fails.
RE: Dynamically create folder structure on UNC share
CODE -->
The above is to backup and to restore you have another vb of the above and swap the CopySource & CopyDest around.
Works well but just need to sort the UNC bit if anyone can help?
RE: Dynamically create folder structure on UNC share
http://www.robvanderwoude.com/vbstech_folders_md.p...
RE: Dynamically create folder structure on UNC share
However, I've come across another issue which I hope you can help me with.
I've discovered that although the code below works well at backing up and restoring the data with overwrites, it doesn't work well when file names are changed in the source as it leaves copied files in the destination from a previous backup. Eventually, the backup folder will continue to get larger and the files will keep being restored.
I think a better way would be to delete the folder before backup but only if the folder exists first and only if the process is about to backup to that location. My issue is I cannot get the
CODE -->
Any help is greatly appreciated.
My complete code:
CODE -->
RE: Dynamically create folder structure on UNC share
http://en.wikipedia.org/wiki/Robocopy
RE: Dynamically create folder structure on UNC share
My new single line of code for logoff is:
CODE -->
and to logon:
CODE -->
far far far more simpler... nice :)
p.s. It would be nice to not show a command prompt during the process but since it's so quick, it's by no means a deal breaker.