[<<]Message[>>]    [<<]Author[>>]    [<<]Subject        [<<]Thread    

Number : 10659 Date : 2005-02-28 Author : des4212001 Subject : Re: Possible to Assign Batch Parameters from WSH? Size(KB) : 3
--- In xxcopy@yahoogroups.com, "Garry Deane" wrote: > > --- In xxcopy@yahoogroups.com, "des4212001" wrote: > > > > Drag & Drop is a really neat feature of WSH, allowing argument > > passing directly from Windows. But there appears to be no > > Renaming method in WSH? I was doinking around trying to see > > if I could pass the WSH arguments to batch paramenters... > > > > Set WshShell = WScript.CreateObject("WScript.Shell") > > Q = Chr(34) : CR = Chr(13) > > For Each Source in WScript.Arguments > > Input = InputBox("Enter new name ?") > > Source = Q+Source+Q > > Input = Q+Input+Q > > WScript.Echo Source & CR & "Rename to " & Input > > WshShell.Run "%windir%\System32\Cmd.exe /K CD C:\ & Rename % > > Source% %Input%",1,true > > Next > > > > This kind of thing doesn't work because CMD can't resolve the > > WHS arguments there. CMD sees literaly "%Source%" & "%Input%", > > not they're values. But I "feel" there must be a way to pass > > the arguments? > > > > I have a little script that copies whatever is selected & droped > > on it to my backups. Actually through a shortcut to it added to > > the Send To menu. Limited only by the argument list length and > > very useful. I was thinking about others to automatically rename > > & delete the multiple copies. The delete method exists and would > > be no trouble, but I can't find any rename? There's probably a > > work a round but it hasn't poped out yet! > > > > DES > > You can use the WSH MoveFile method to rename a file. See > http://www.windowsitpro.com/Articles/Index.cfm? > ArticleID=15287&DisplayTab=Article > > Also in WSH, you don't put % signs around variables. Your > command should be like the following: > > WshShell.Run "%windir%\System32\Cmd.exe /K CD C:\ & > Rename "+Source+" "+Input,1,true > > Garry I'll check that out as the answer could still be valuable. However, in true M$ fashion, the WSH "Rename Method" is found under the Name Property! (In the Windows Script Technologies Help file | Script Runtime | File System Object Basics | Properties | Name Property.) So I can accomplish the immediate goal without involving CMD, as so... Dim FSO Set FSO = CreateObject("Scripting.FileSystemObject") Title = "Rename All 3 Copies" For Each Source in WScript.Arguments Drive = Left(Source,1) PPath = Right(Source,Len(Source)-1) If InStr("CDEFGH",Drive) Then Val = Asc(Drive) D2 = Chr(Val + 6) D3 = Chr(Val + 12) Else Msg = MsgBox("Drive "&Drive&": is Not a Valid System Source!",16,Title) Exit For End If Input = InputBox("Enter new name ", Title) If Input = "" Then Exit For Obj = Source RenameObject(Obj) Obj = D2 + PPath RenameObject(Obj) Obj = D3 + PPath RenameObject(Obj) Next Function RenameObject(Obj) If FSO.FileExists(Obj) Then Set F = FSO.GetFile(Obj) Else Set F = FSO.GetFolder(Obj) End If F.Name = Input End Function This partitular thing deals with my overly complicated setup of 3 disks of 6 partitions each, assigned in asending order. A shortcut to the actual script placed in the Send To menu allows whatever's selected (up to the command line length) to be renamed on all 3 copies from the context menu. Next, a Delete3 is order (have the Copy). These tasks are taken care of by the xxcopy routiens that maintain the backups, but I'm a stickler for keeping some items (mostly data outside the OS) as fresh as possible. Whenever making a small organization change for instance, then I can instantly do all 3 copies. Thanks: DES
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.