Hello i was looking in a way to make a automatic copy script from .txt files and i run in to this website. I never done even one VBS script and dont know if this is possible. I get "list.txt" files from users on the network that need to copy their files and folders, they are always different files/folders but a example "list.txt" looks like this:
e:\user\diz\documents\new folder\
e:\user\diz\video\new client\i need to copy this folders/files to a external memory stick (so not alway copying to the same location) (so maybe a popup window asking: to what location?) and keeping the folder structure from the disk to the USB.
As the disks are on a network and sometimes really large folders i like to run each copy separably with a little bling or message when its done. So i know what one is finished.
Is this possible with VBS scripting?
Q&D: Set fList = CreateObject("Scripting.FileSystemObject").OpenTextFile("list.txt") Set dest = CreateObject("Shell.Application") _ .BrowseForFolder(0, "Destination Selection", &H51) Do Until fList.AtEndOfStream dest.CopyHere Trim(fList.ReadLine), 16 Loop
Razor sharp dude! It works like a charm! I tried all night yesterday.
Is it possible to keep the subfolders also on the destination disk?
example from: "list.txt"
e:\user\diz\documents\new folder\
Destination Selection "h:"
now the output is:
h:\new folder\Is it possible to make it:
h:\user\diz\documents\new folder\So keep folder structure "\user\diz\documents\" ? so its easy to copy back when they are done?
I could, but I don't see how the copy back would be easier with h:\user\diz\documents\new folder\ instead of h:\new folder\user\diz\documents\. In the latter case, you just copy everything in the h:\new folder to, presumably, c:\.
In the former case, you have to look at every folder on the h:\ for your new folder, then copy that to the relevant directory.
Tanx Razor for taking your time reading my post. If the user wants two folder but from different directory's, but the folder names are the same.
e:\user\diz\documents\new folder\
e:\user\diz\video\client2\new folder\output would be:
h:\new folder\
h:\new folder\That means all files from 2 folder would come in one folder.
Could u write a little explanation to your code so i can try extending it my self?
I also want to add copy only *.doc!
Sorry it took a while; I didn't have much time beyond a Q&D script. This should be closer to what you want: Set fso = CreateObject("Scripting.FileSystemObject") Set shell = CreateObject("Shell.Application") Set fList = fso.OpenTextFile("list.txt") rootDest = shell.BrowseForFolder(0, "Destination Selection", &H51).Self.Path Do Until fList.AtEndOfStream line = Trim(fList.ReadLine) If Len(line) Then 'Ignore empty lines dest = fso.GetParentFolderName( _ rootDest & Mid(line, Len(fso.GetDriveName(line)) + 1)) If Not fso.FolderExists(dest) Then _ MakeFolder dest Set target = shell.Namespace(dest) target.CopyHere line, 16 End If Loop Sub MakeFolder(sPath) If sPath = "" Then _ Exit Sub parent = fso.GetParentFolderName(sPath) If Not fso.FolderExists(parent) Then _ MakeFolder parent fso.CreateFolder sPath End Sub
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |