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

Number : 10650 Date : 2005-02-27 Author : Garry Deane Subject : Re: Possible to Assign Batch Parameters from WSH? Size(KB) : 1
--- 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
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.