Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Parsing lines from files and moveing dirs

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3179
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Parsing lines from files and moveing dirs
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Parsing lines from files and moveing dirs - 5/31/2005 7:18:17 PM   
  Netguard3

 

Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
Hey guys,

just woundering,
read some of the other threads regarding parsing a line into a script.
i have a files with names of dirs like this:

;data.dat
dirA
dirB
dirC
...
if i want to the script to take the each line from the file and move a folder called Data-Folder wich is in all the folders (dirA,DirB,dirC ..)
how would i come about this ?
i want it to move the dir to another drive but still keep the name of the the dir (dirA ... ) and only compy the folder named Data-Folder with subfolders ofcause. but many other folders are in the dirA and dirB folders..

any ideas or links ?

_____________________________

Power To The People! ;)
 
 
Post #: 1
 
 Re: Parsing lines from files and moveing dirs - 5/31/2005 7:22:08 PM   
  Netguard3

 

Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
not sure, what would be the best,
i have all the dir names in a file.
but if it is better to have it scan the entire drive for the folder name i want to copy, any insider ideas ? :)

(in reply to Netguard3)
 
 
Post #: 2
 
 Re: Parsing lines from files and moveing dirs - 6/1/2005 12:16:50 AM   
  mbouchard


Posts: 1922
Score: 16
Joined: 5/15/2003
From: USA
Status: offline
Let me get this straight. You want to parse through data.dat which contains a list of folders, Dira, B, C etc. You then would want to move a folder the folder to a new directory. So, you would want to move C:\DirA and all it's subfolder to D:\DirA.

(in reply to Netguard3)
 
 
Post #: 3
 
 Re: Parsing lines from files and moveing dirs - 6/1/2005 1:02:26 AM   
  Netguard3

 

Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
i have the
folders:
\DirA\
\DirB\
\DirC\
alle the folders contains another folder named eks. documents.
and i only want to move the documnts from all the dirs (docuemnts folder and the subfolders in the documents folder)
But not other dirs located in DirA,B and C. Only the documents folder.. you follow ?

(in reply to Netguard3)
 
 
Post #: 4
 
 Re: Parsing lines from files and moveing dirs - 6/1/2005 1:32:53 AM   
  Netguard3

 

Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
Will post my code later.

(in reply to Netguard3)
 
 
Post #: 5
 
 Re: Parsing lines from files and moveing dirs - 6/1/2005 1:56:05 AM   
  Netguard3

 

Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
i was able to build one from:

http://www.visualbasicscript.com/topic.asp?TOPIC_ID=2818&SearchTerms=remove,printer

thx again :)

(in reply to Netguard3)
 
 
Post #: 6
 
 Re: Parsing lines from files and moveing dirs - 6/1/2005 2:41:26 AM   
  Netguard3

 

Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
It wont load the correct default printer

any ideas ?

Option Explicit
Const NEW_PRINT_SERVER = "NEWPRINTSERVER"
Const HKEY_CURRENT_USER = &H80000001

Dim oReg, WshNetwork, oPrinters
Dim strComputer, strKeyPath, strValueName, strValue, strDefault, PrinterPath, strPrinterName
Dim intComma, i, intCount, intPrinterLen

On Error Resume Next

Set WshNetwork = WScript.CreateObject ("WScript.Network")
Set oPrinters = WshNetwork.EnumPrinterConnections
strComputer = "."
strDefault = ""
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows"
strKeyPathXP = "Software\Microsoft\Windows NT\CurrentVersion"
strValueName = "Device"
strValueNameXP = "Devices"
oReg.GetStringValue HKEY_CURRENT_USER,strKeyPath,strValueName,strValue
cScript.Echo(strvalue)
intComma = InStr(1,strValue,",")
cScript.echo(strValue)
strDefault = Mid(strValue, 12, intComma - 8)
cScript.Echo(strDefault)

i = 0
strPrinterName = ""
For i = 1 To oPrinters.Count Step 2
intCount = intCount +1
intPrinterLen = Len(oPrinters.Item(i))
MsgBox(intPrinter)
strPrinterName = Mid(oPrinters.Item (i), 12, intPrinterLen - 7)
WScript.Echo(NEW_PRINT_SERVER & strPrinterName)
Err.clear
WshNetwork.AddWindowsPrinterConnection NEW_PRINT_SERVER & strPrinterName
'MsgBox "Installed " & strPrinterName

If Err Then
MsgBox "Printer Does not Exist"

Elseif (oPrinters.Item (i))= NEW_PRINT_SERVER & strPrinterName Then
MsgBox "New Printer Not Deleted"

Else
'MsgBox "Removing " & oPrinters.Item (i)

PrinterPath = oPrinters.Item (i)
WshNetwork.RemovePrinterConnection PrinterPath
End If
Next

WshNetwork.SetDefaultPrinter NEW_PRINT_SERVER & strDefault
MsgBox "Your printers have been migrated!"
Set WshNetwork = flaf

(in reply to Netguard3)
 
 
Post #: 7
 
 Re: Parsing lines from files and moveing dirs - 6/2/2005 1:06:07 AM   
  Netguard3

 

Posts: 14
Score: 0
Joined: 5/12/2005
From: Denmark
Status: offline
got it.

Dim WS_Printers
DefaultPrinterName = ""
spoint = 0
SetDefault = 0
set WshShell = CreateObject("WScript.shell")

from_sv = "\\servera" 'This should be the name of the old server.
to_sv = "\\serverb" 'This should be the name of your new server.

On Error Resume Next
key = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device"
DefaultPrinter = LCase(WshShell.RegRead (key))
If Err.Number <> 0 Then
DefaultPrinterName = ""
else
spoint = instr(3,DefaultPrinter,"\")+1
DefaultPrinterServer = left(DefaultPrinter,spoint-2)
if DefaultPrinterServer = from_sv then
DefaultPrinterName = mid(DefaultPrinter,spoint,len(DefaultPrinter)-spoint+1)
end if
end if
Set WshNet = CreateObject("WScript.Network")
Set WS_Printers = WshNet.EnumPrinterConnections
For Loop_Counter = 0 To WS_Printers.Count - 1 Step 2
PrinterPath = lcase(WS_Printers(Loop_Counter + 1))
if LEFT(PrinterPath,len(from_sv)) = from_sv then
spoint = instr(3,PrinterPath,"\")+1
PrinterName = mid(PrinterPath,spoint,len(PrinterPath)-spoint+1)
WshNet.RemovePrinterConnection from_sv+"\"+PrinterName
WshNet.AddWindowsPrinterConnection to_sv+"\"+PrinterName
if DefaultPrinterName = PrinterName then
WshNet.SetDefaultPrinter to_sv+"\"+PrinterName
end if
end if
Next
Set WS_Printers = Nothing
Set WshNet = Nothing
Set WshShell = Nothing

(in reply to Netguard3)
 
 
Post #: 8
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Parsing lines from files and moveing dirs Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts