If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#21
|
|||
|
|||
running many files through the same command
Is the called program (pre602.exe ) a window's program? That is about
the only explanation assuming everything is configured correctly. The script simply builds a batch file and launches it. If you want to examine the batch file, then comment out the line that deletes the temporary batch file and look at it (in %temp%.) It will something look like this- @echo off pre602.exe /d:5 file1.wp file1.602 pre602.exe /d:5 file2.wp file2.602 pre602.exe /d:5 file3.wp file3.602 pause cls On your question; %1 tells the explorer shell to pass the explicit file-path-name, and has nothing to do with it being a bat file. I don't know how to easily parse the name part out. Script is probably the easiest way, without writing your own string parser. Hope your eye surgery went ok. No hurry... We'll be here :-) "Ivan Bútora" wrote in message ... Thanks for the response. I tried the script, but it still launched a separate window for each file. I should probably do some studying on scripting, but I don't have the time for that now. I had one more question about batch files: Is there any way to refer to a file or folder without the full path. I find that "%1" puts in the full path of the file, but I need just the name. (this is not related to the conversion thing) Ivan P.S. I am having laser eye surgery now, so I won't be able to do anything with the computer for at least a week - thus, my response might be delayed. "Bill Blanton" wrote in message ... Well, for that you'd probably need a batch file, unless your program accepts multiple arguments. It's very difficult to call into a running DOS VM command shell from outside the shell. (I don't know how, anyway) Try this script. It creates a temporary bat file in %temp% with multiple command lines, and then runs it. Dim oFSO, oShell Dim aCmdArgs Dim sTempBatFile, sBaseName, sCmdline Dim hDestFile, oDestTextStream Set oFSO=CreateObject("Scripting.FileSystemObject") Set oShell = wscript.CreateObject("WScript.Shell") Const TEMP_DIR=2 Const WRITE_ONLY=2 Const ASCII=0 Set aCmdArgs=wscript.arguments If aCmdArgs.count 0 Then ' ****this is one line**** sTempBatFile = oFSO.GetSpecialFolder(TEMP_DIR) & "\" & oFSO.GetBaseName(oFSO.GetTempName) & ".bat" oFSO.CreateTextFile sTempBatFile Set hDestFile=oFSO.GetFile(sTempBatFile) Set oDestTextStream=hDestFile.OpenAsTextStream(WRITE_O NLY,ASCII) oDestTextStream.WriteLine("@echo off") For Each x In aCmdArgs sBaseName = oFSO.GetBaseName(x) sCmdline="pre602.exe /d:5 "+x+" "+sBaseName+".602" oDestTextStream.WriteLine(sCmdline) Next oDestTextStream.WriteLine("pause") oDestTextStream.WriteLine("cls") oDestTextStream.Close oShell.Run sTempBatFile,,TRUE oFSO.DeleteFile(sTempBatFile) End If wscript.quit "Ivan Bútora" wrote in message ... Thanks, this worked fine as well. (Although I guess really I should learn something about windows scripting...) One other thing I'm wondering while we're at this - when I select multiple files in explorer, and then perform the 'convert' action on those, multiple windows open, i.e. each one is done in its own DOS session. Would there be any way to do it so that when I select multiple files, they're all done in one DOS session? Ivan "Bill Blanton" wrote in message ... "Ivan Bútora" wrote in message ... What I am trying to do is this. I want to be able to, in explorer, right click on the file, select "convert" and have the file xxx.wp be converted to xxx.602. Thus what I am doing is defining a custom action called 'convert to .602' for all .wp files in View - Folder Options - File types. As I said, my problem is actually already solved, since the command that will do what I want is: pre602.exe /d:5 %1 .602 (Edit action 'convert' - Application used to perform action) What I am asking now is, *if* pre602.exe was not smart enough to automatically put in the part of the filename before the extension, how would I accomplish what I want, i.e. how would I refer to a filename sans extension. It's not very easy to parse strings with batch files, and there is no command to return the base of a filename. You might want to use windows scripting instead, which does have a method to return a filename's base. Copy/Paste/Save as convert.vbs (or whatever). ''''''''''''''''''''''''''' Dim oFSO Set oFSO=CreateObject("Scripting.FileSystemObject") Dim oShell Set oShell = wscript.CreateObject("WScript.Shell") Dim aCmdArgs Set aCmdArgs=wscript.arguments If aCmdArgs.count 0 Then For Each x In aCmdArgs sBaseName = oFSO.GetBaseName(x) sCmdline="pre602.exe /d:5 "+x+" "+sBaseName+".602" MsgBox sCmdline 'oShell.Run sCmdline,1,TRUE Next End If wscript.quit ''''''''''''''''''''''''''' The reg entry would then be wscript (pathto)\convert.vbs "%1" The script as it is will just show a message box of the commandline to be executed. If that tests okay, then delete the line containing MsgBox sCmdline and remove the starting quote character ( ' comment) from the line oShell.Run sCmdline,1,TRUE This should also work for multiple file selections. |
#22
|
|||
|
|||
running many files through the same command
Hi again,
well, I can generally see OK now, so I'm back (somewhat). Thanks for = your response. I understand that there is no easy way to refer to a file = name without the path in explorer. As for the script, it does create the .bat files in %temp%, but it = creates a separate .bat file for each selected .wp file rather than one = ..bat file with everything in it. Also, is it possible to substitute long = file names with 8.3 file names - pre602.exe doesn't understand long file = names. Thanks, Ivan "Bill Blanton" wrote in message = ... Is the called program (pre602.exe ) a window's program? That is about the only explanation assuming everything is configured correctly. The script simply builds a batch file and launches it. If you want to = examine the batch file, then comment out the line that deletes the temporary batch file and look at it (in %temp%.) =20 It will something look like this- =20 @echo off pre602.exe /d:5 file1.wp file1.602 pre602.exe /d:5 file2.wp file2.602 pre602.exe /d:5 file3.wp file3.602 pause cls =20 On your question; %1 tells the explorer shell to pass the explicit = file-path-name, and has nothing to do with it being a bat file. I don't know how to = easily parse the name part out. Script is probably the easiest way, without writing = your own string parser. =20 Hope your eye surgery went ok. No hurry... We'll be here :-) =20 =20 "Ivan B=FAtora" wrote in message = ... Thanks for the response. I tried the script, but it still launched a = separate window for each file. I should probably do some studying on scripting, but I don't have the time for that now. I had one more question about batch files: Is there any way to refer = to a file or folder without the full path. I find that "%1" puts in the full path of the file, but I need just the name. (this is = not related to the conversion thing) =20 Ivan =20 P.S. I am having laser eye surgery now, so I won't be able to do = anything with the computer for at least a week - thus, my response might be delayed. =20 =20 "Bill Blanton" wrote in message = ... Well, for that you'd probably need a batch file, unless your program accepts multiple arguments. It's very difficult to call into a = running DOS VM command shell from outside the shell. (I don't know how, anyway) Try this script. It creates a temporary bat file in %temp% with = multiple command lines, and then runs it. Dim oFSO, oShell Dim aCmdArgs Dim sTempBatFile, sBaseName, sCmdline Dim hDestFile, oDestTextStream Set oFSO=3DCreateObject("Scripting.FileSystemObject") Set oShell =3D wscript.CreateObject("WScript.Shell") Const TEMP_DIR=3D2 Const WRITE_ONLY=3D2 Const ASCII=3D0 Set aCmdArgs=3Dwscript.arguments If aCmdArgs.count 0 Then ' ****this is one line**** sTempBatFile =3D oFSO.GetSpecialFolder(TEMP_DIR) & "\" & = oFSO.GetBaseName(oFSO.GetTempName) & ".bat" oFSO.CreateTextFile sTempBatFile Set hDestFile=3DoFSO.GetFile(sTempBatFile) Set oDestTextStream=3DhDestFile.OpenAsTextStream(WRITE _ONLY,ASCII) oDestTextStream.WriteLine("@echo off") For Each x In aCmdArgs sBaseName =3D oFSO.GetBaseName(x) sCmdline=3D"pre602.exe /d:5 "+x+" "+sBaseName+".602" oDestTextStream.WriteLine(sCmdline) Next oDestTextStream.WriteLine("pause") oDestTextStream.WriteLine("cls") oDestTextStream.Close oShell.Run sTempBatFile,,TRUE oFSO.DeleteFile(sTempBatFile) End If wscript.quit "Ivan B=FAtora" wrote in message = ... Thanks, this worked fine as well. (Although I guess really I should = learn something about windows scripting...) One other thing I'm wondering while we're at this - when I select = multiple files in explorer, and then perform the 'convert' action on those, multiple windows open, i.e. each one is done in its own = DOS session. Would there be any way to do it so that when I select multiple files, they're all done in one DOS session? Ivan "Bill Blanton" wrote in message = ... "Ivan B=FAtora" wrote in message = ... What I am trying to do is this. I want to be able to, in = explorer, right click on the file, select "convert" and have the file = xxx.wp be converted to xxx.602. Thus what I am doing is defining a custom = action called 'convert to .602' for all .wp files in View - Folder = Options - File types. As I said, my problem is actually already solved, = since the command that will do what I want is: pre602.exe /d:5 %1 .602 (Edit action 'convert' - Application = used to perform action) What I am asking now is, *if* pre602.exe was not smart enough to automatically put in the part of the filename before the = extension, how would I accomplish what I want, i.e. how would I refer to a filename sans extension. It's not very easy to parse strings with batch files, and there is = no command to return the base of a filename. You might want to use windows scripting instead, which does have a method to return a filename's base. Copy/Paste/Save as convert.vbs (or whatever). ''''''''''''''''''''''''''' Dim oFSO Set oFSO=3DCreateObject("Scripting.FileSystemObject") Dim oShell Set oShell =3D wscript.CreateObject("WScript.Shell") Dim aCmdArgs Set aCmdArgs=3Dwscript.arguments If aCmdArgs.count 0 Then For Each x In aCmdArgs sBaseName =3D oFSO.GetBaseName(x) sCmdline=3D"pre602.exe /d:5 "+x+" "+sBaseName+".602" MsgBox sCmdline 'oShell.Run sCmdline,1,TRUE Next End If wscript.quit ''''''''''''''''''''''''''' The reg entry would then be wscript (pathto)\convert.vbs "%1" The script as it is will just show a message box of the = commandline to be executed. If that tests okay, then delete the line = containing MsgBox sCmdline and remove the starting quote character ( ' comment) from the line oShell.Run sCmdline,1,TRUE This should also work for multiple file selections. =20 |
#23
|
|||
|
|||
running many files through the same command
Glad to hear you are ok.
I don't understand why it is creating a separate batch for every parameter. In my testing with another DOS program it only creates one batch and then runs it. Mabey you could send me the program, and a couple of small *.wp files, so I can test it myself. In the meantime, here's the script with a GetShortName( ) function added. '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' Dim oFSO, oShell Dim aCmdArgs Dim sTempBatFile, sShortName, sBaseName, sCmdline Dim hDestFile, oDestTextStream Set oFSO=CreateObject("Scripting.FileSystemObject") Set oShell = wscript.CreateObject("WScript.Shell") Const TEMP_DIR=2 Const WRITE_ONLY=2 Const ASCII=0 Set aCmdArgs=wscript.arguments If aCmdArgs.count 0 Then sTempBatFile = oFSO.GetSpecialFolder(TEMP_DIR) & "\" & oFSO.GetBaseName(oFSO.GetTempName) & ".bat" oFSO.CreateTextFile sTempBatFile Set hDestFile=oFSO.GetFile(sTempBatFile) Set oDestTextStream=hDestFile.OpenAsTextStream(WRITE_O NLY,ASCII) oDestTextStream.WriteLine("@echo off") For Each x In aCmdArgs sShortName = GetShortName(x) sBaseName = oFSO.GetBaseName(sShortName) sCmdline="pre602.exe /d:5 "+sShortName+" "+sBaseName+".602" oDestTextStream.WriteLine(sCmdline) Next oDestTextStream.WriteLine("pause") oDestTextStream.WriteLine("cls") oDestTextStream.Close oShell.Run sTempBatFile,,TRUE oFSO.DeleteFile(sTempBatFile) End If wscript.quit Function GetShortName(filespec) Dim f Set f = oFSO.GetFile(filespec) GetShortName = f.ShortName End Function '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' "Ivan Bútora" wrote in message ... Hi again, well, I can generally see OK now, so I'm back (somewhat). Thanks for your response. I understand that there is no easy way to refer to a file name without the path in explorer. As for the script, it does create the .bat files in %temp%, but it creates a separate .bat file for each selected .wp file rather than one .bat file with everything in it. Also, is it possible to substitute long file names with 8.3 file names - pre602.exe doesn't understand long file names. Thanks, Ivan "Bill Blanton" wrote in message ... Is the called program (pre602.exe ) a window's program? That is about the only explanation assuming everything is configured correctly. The script simply builds a batch file and launches it. If you want to examine the batch file, then comment out the line that deletes the temporary batch file and look at it (in %temp%.) It will something look like this- @echo off pre602.exe /d:5 file1.wp file1.602 pre602.exe /d:5 file2.wp file2.602 pre602.exe /d:5 file3.wp file3.602 pause cls |
#24
|
|||
|
|||
running many files through the same command
OK, I'm sending you some test files and the program, but first let me =
make sure I'm doing this right. In "application used to perform this = action", I have: C:\WINDOWS\WSCRIPT.EXE (...)\convert.vbs "%1" Is that how it should be? Thanks, Ivan "Bill Blanton" wrote in message = ... Glad to hear you are ok. =20 I don't understand why it is creating a separate batch for every = parameter. In my testing with another DOS program it only creates one batch and then runs it. Mabey you could send me the program, and a couple of small *.wp files, so I can test it myself. =20 In the meantime, here's the script with a GetShortName( ) function = added. =20 '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' =20 Dim oFSO, oShell Dim aCmdArgs Dim sTempBatFile, sShortName, sBaseName, sCmdline Dim hDestFile, oDestTextStream =20 Set oFSO=3DCreateObject("Scripting.FileSystemObject") Set oShell =3D wscript.CreateObject("WScript.Shell") =20 Const TEMP_DIR=3D2 Const WRITE_ONLY=3D2 Const ASCII=3D0 =20 Set aCmdArgs=3Dwscript.arguments =20 If aCmdArgs.count 0 Then =20 sTempBatFile =3D oFSO.GetSpecialFolder(TEMP_DIR) & "\" & = oFSO.GetBaseName(oFSO.GetTempName) & ".bat" =20 oFSO.CreateTextFile sTempBatFile =20 Set hDestFile=3DoFSO.GetFile(sTempBatFile) Set oDestTextStream=3DhDestFile.OpenAsTextStream(WRITE _ONLY,ASCII) =20 oDestTextStream.WriteLine("@echo off") =20 For Each x In aCmdArgs sShortName =3D GetShortName(x) sBaseName =3D oFSO.GetBaseName(sShortName) sCmdline=3D"pre602.exe /d:5 "+sShortName+" "+sBaseName+".602" oDestTextStream.WriteLine(sCmdline) Next =20 oDestTextStream.WriteLine("pause") oDestTextStream.WriteLine("cls") oDestTextStream.Close =20 oShell.Run sTempBatFile,,TRUE =20 oFSO.DeleteFile(sTempBatFile) =20 End If =20 wscript.quit =20 =20 Function GetShortName(filespec) Dim f Set f =3D oFSO.GetFile(filespec) GetShortName =3D f.ShortName End Function =20 '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' =20 =20 =20 "Ivan B=FAtora" wrote in message = ... Hi again, =20 well, I can generally see OK now, so I'm back (somewhat). Thanks for = your response. I understand that there is no easy way to refer to a file name without the path in explorer. As for the script, it does create the .bat files in %temp%, but it = creates a separate .bat file for each selected .wp file rather than one .bat file with everything in it. Also, is it possible to = substitute long file names with 8.3 file names - pre602.exe doesn't understand long file names. =20 Thanks, =20 Ivan =20 =20 "Bill Blanton" wrote in message = ... Is the called program (pre602.exe ) a window's program? That is = about the only explanation assuming everything is configured correctly. = The script simply builds a batch file and launches it. If you want to = examine the batch file, then comment out the line that deletes the temporary batch file and look at it (in %temp%.) It will something look like this- @echo off pre602.exe /d:5 file1.wp file1.602 pre602.exe /d:5 file2.wp file2.602 pre602.exe /d:5 file3.wp file3.602 pause cls =20 |
#25
|
|||
|
|||
running many files through the same command
You are right, Ivan. I thought explorer passed "%1" like so
program.exe arg1 arg2 ... argn but, it is as you say program.exe arg1 program.exe arg2 .... program.exe argn This wouldn't be too much of a problem for a Window's program, because there are ways to determine if there is already an instance of "self" running. However, wscript being more of a command-line tool than a full fledged "window" app, it doesn't work that way. I searched for ways to pass multiple parameters in one command, via the registry, but came up empty. The only thing I can think of is to put a shortcut somewhere to convert.vbs and drag/drop on the shortcut, or put a shortcut in \windows\sendto and do a "send to...". This does pass the parameters as "program.exe arg1 arg2 ... argn" If so, the script file would need to be slightly reworked. The full path to convert.vbs would need to be included, and I think the full path to the first argument. As it is now, I get the error: Soubor TEST1.WP nebyl nalezen Stiskni klavesu... Soubor TEST2.WP nebyl nalezen Stiskni klavesu... I *think* it might mean "file not found" or something similar, but have no idea. Let me know, and I'll rework it if you want to do that. Otherwise, you'll have to open multiple windows or convert one file at a time. You can remove the "pause" statement in those cases, if you want. You just see the DOS windows "flash". "Ivan Bútora" wrote in message ... OK, I'm sending you some test files and the program, but first let me make sure I'm doing this right. In "application used to perform this action", I have: C:\WINDOWS\WSCRIPT.EXE (...)\convert.vbs "%1" Is that how it should be? Thanks, Ivan "Bill Blanton" wrote in message ... Glad to hear you are ok. I don't understand why it is creating a separate batch for every parameter. In my testing with another DOS program it only creates one batch and then runs it. Mabey you could send me the program, and a couple of small *.wp files, so I can test it myself. In the meantime, here's the script with a GetShortName( ) function added. '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' Dim oFSO, oShell Dim aCmdArgs Dim sTempBatFile, sShortName, sBaseName, sCmdline Dim hDestFile, oDestTextStream Set oFSO=CreateObject("Scripting.FileSystemObject") Set oShell = wscript.CreateObject("WScript.Shell") Const TEMP_DIR=2 Const WRITE_ONLY=2 Const ASCII=0 Set aCmdArgs=wscript.arguments If aCmdArgs.count 0 Then sTempBatFile = oFSO.GetSpecialFolder(TEMP_DIR) & "\" & oFSO.GetBaseName(oFSO.GetTempName) & ".bat" oFSO.CreateTextFile sTempBatFile Set hDestFile=oFSO.GetFile(sTempBatFile) Set oDestTextStream=hDestFile.OpenAsTextStream(WRITE_O NLY,ASCII) oDestTextStream.WriteLine("@echo off") For Each x In aCmdArgs sShortName = GetShortName(x) sBaseName = oFSO.GetBaseName(sShortName) sCmdline="pre602.exe /d:5 "+sShortName+" "+sBaseName+".602" oDestTextStream.WriteLine(sCmdline) Next oDestTextStream.WriteLine("pause") oDestTextStream.WriteLine("cls") oDestTextStream.Close oShell.Run sTempBatFile,,TRUE oFSO.DeleteFile(sTempBatFile) End If wscript.quit Function GetShortName(filespec) Dim f Set f = oFSO.GetFile(filespec) GetShortName = f.ShortName End Function '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' "Ivan Bútora" wrote in message ... Hi again, well, I can generally see OK now, so I'm back (somewhat). Thanks for your response. I understand that there is no easy way to refer to a file name without the path in explorer. As for the script, it does create the .bat files in %temp%, but it creates a separate .bat file for each selected .wp file rather than one .bat file with everything in it. Also, is it possible to substitute long file names with 8.3 file names - pre602.exe doesn't understand long file names. Thanks, Ivan "Bill Blanton" wrote in message ... Is the called program (pre602.exe ) a window's program? That is about the only explanation assuming everything is configured correctly. The script simply builds a batch file and launches it. If you want to examine the batch file, then comment out the line that deletes the temporary batch file and look at it (in %temp%.) It will something look like this- @echo off pre602.exe /d:5 file1.wp file1.602 pre602.exe /d:5 file2.wp file2.602 pre602.exe /d:5 file3.wp file3.602 pause cls |
#26
|
|||
|
|||
running many files through the same command
I must admit that I don't quite understand where the accumulation of =
arguments actually happens, and how the send to menu is distinctive in = this sense - but I guess I would have to understand the actually script = in order to get a good sense of what's going on. Anyway, I did create a shortcut to convert.vbs in C:\Windows\SendTo, and = now it indeed just creates one batch file, but gives the errors that you = mentioned. Those errors indeed mean "file (...) not found" in Czech. Is = the issue now the full path to the files that we want to convert? Thanks for your help with this, Ivan "Bill Blanton" wrote in message = ... You are right, Ivan. I thought explorer passed "%1" like so =20 program.exe arg1 arg2 ... argn =20 but, it is as you say =20 program.exe arg1 program.exe arg2 ... program.exe argn =20 This wouldn't be too much of a problem for a Window's program, because there are ways to determine if there is already an instance of "self" = running. However, wscript being more of a command-line tool than a full fledged "window" app, it doesn't work that way. =20 I searched for ways to pass multiple parameters in one command, via = the registry, but came up empty. =20 The only thing I can think of is to put a shortcut somewhere to = convert.vbs and drag/drop on the shortcut, or put a shortcut in \windows\sendto = and do a "send to...". This does pass the parameters as "program.exe arg1 arg2 ... argn" =20 If so, the script file would need to be slightly reworked. The full = path to convert.vbs would need to be included, and I think the full path to = the first argument. As it is now, I get the error: =20 Soubor TEST1.WP nebyl nalezen =20 Stiskni klavesu... Soubor TEST2.WP nebyl nalezen =20 Stiskni klavesu... =20 =20 I *think* it might mean "file not found" or something similar, but = have no idea. =20 Let me know, and I'll rework it if you want to do that. Otherwise, = you'll have to open multiple windows or convert one file at a time. You can remove = the "pause" statement in those cases, if you want. You just see the DOS = windows "flash". =20 =20 =20 "Ivan B=FAtora" wrote in message = ... OK, I'm sending you some test files and the program, but first let me = make sure I'm doing this right. In "application used to perform this action", I have: =20 C:\WINDOWS\WSCRIPT.EXE (...)\convert.vbs "%1" =20 Is that how it should be? =20 Thanks, =20 Ivan =20 =20 =20 "Bill Blanton" wrote in message = ... Glad to hear you are ok. I don't understand why it is creating a separate batch for every = parameter. In my testing with another DOS program it only creates one batch and then runs it. Mabey you could send me the program, and a couple of small *.wp files, so I can test it myself. In the meantime, here's the script with a GetShortName( ) function = added. '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' Dim oFSO, oShell Dim aCmdArgs Dim sTempBatFile, sShortName, sBaseName, sCmdline Dim hDestFile, oDestTextStream Set oFSO=3DCreateObject("Scripting.FileSystemObject") Set oShell =3D wscript.CreateObject("WScript.Shell") Const TEMP_DIR=3D2 Const WRITE_ONLY=3D2 Const ASCII=3D0 Set aCmdArgs=3Dwscript.arguments If aCmdArgs.count 0 Then sTempBatFile =3D oFSO.GetSpecialFolder(TEMP_DIR) & "\" & = oFSO.GetBaseName(oFSO.GetTempName) & ".bat" oFSO.CreateTextFile sTempBatFile Set hDestFile=3DoFSO.GetFile(sTempBatFile) Set oDestTextStream=3DhDestFile.OpenAsTextStream(WRITE _ONLY,ASCII) oDestTextStream.WriteLine("@echo off") For Each x In aCmdArgs sShortName =3D GetShortName(x) sBaseName =3D oFSO.GetBaseName(sShortName) sCmdline=3D"pre602.exe /d:5 "+sShortName+" "+sBaseName+".602" oDestTextStream.WriteLine(sCmdline) Next oDestTextStream.WriteLine("pause") oDestTextStream.WriteLine("cls") oDestTextStream.Close oShell.Run sTempBatFile,,TRUE oFSO.DeleteFile(sTempBatFile) End If wscript.quit Function GetShortName(filespec) Dim f Set f =3D oFSO.GetFile(filespec) GetShortName =3D f.ShortName End Function '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' "Ivan B=FAtora" wrote in message = ... Hi again, well, I can generally see OK now, so I'm back (somewhat). Thanks for = your response. I understand that there is no easy way to refer to a file name without the path in explorer. As for the script, it does create the .bat files in %temp%, but it = creates a separate .bat file for each selected .wp file rather than one .bat file with everything in it. Also, is it possible to = substitute long file names with 8.3 file names - pre602.exe doesn't understand long file names. Thanks, Ivan "Bill Blanton" wrote in message = ... Is the called program (pre602.exe ) a window's program? That is = about the only explanation assuming everything is configured correctly. = The script simply builds a batch file and launches it. If you want to = examine the batch file, then comment out the line that deletes the = temporary batch file and look at it (in %temp%.) It will something look like this- @echo off pre602.exe /d:5 file1.wp file1.602 pre602.exe /d:5 file2.wp file2.602 pre602.exe /d:5 file3.wp file3.602 pause cls =20 |
#27
|
|||
|
|||
running many files through the same command
Also, what does %* mean when it's used in a similar context as %1? Is =
there a web page somewhere where one can read all about the = possibilities for explorer file manipulation? Thanks, Ivan "Bill Blanton" wrote in message = ... You are right, Ivan. I thought explorer passed "%1" like so =20 program.exe arg1 arg2 ... argn =20 but, it is as you say =20 program.exe arg1 program.exe arg2 ... program.exe argn =20 This wouldn't be too much of a problem for a Window's program, because there are ways to determine if there is already an instance of "self" = running. However, wscript being more of a command-line tool than a full fledged "window" app, it doesn't work that way. =20 I searched for ways to pass multiple parameters in one command, via = the registry, but came up empty. =20 The only thing I can think of is to put a shortcut somewhere to = convert.vbs and drag/drop on the shortcut, or put a shortcut in \windows\sendto = and do a "send to...". This does pass the parameters as "program.exe arg1 arg2 ... argn" =20 If so, the script file would need to be slightly reworked. The full = path to convert.vbs would need to be included, and I think the full path to = the first argument. As it is now, I get the error: =20 Soubor TEST1.WP nebyl nalezen =20 Stiskni klavesu... Soubor TEST2.WP nebyl nalezen =20 Stiskni klavesu... =20 =20 I *think* it might mean "file not found" or something similar, but = have no idea. =20 Let me know, and I'll rework it if you want to do that. Otherwise, = you'll have to open multiple windows or convert one file at a time. You can remove = the "pause" statement in those cases, if you want. You just see the DOS = windows "flash". =20 =20 =20 "Ivan B=FAtora" wrote in message = ... OK, I'm sending you some test files and the program, but first let me = make sure I'm doing this right. In "application used to perform this action", I have: =20 C:\WINDOWS\WSCRIPT.EXE (...)\convert.vbs "%1" =20 Is that how it should be? =20 Thanks, =20 Ivan =20 =20 =20 "Bill Blanton" wrote in message = ... Glad to hear you are ok. I don't understand why it is creating a separate batch for every = parameter. In my testing with another DOS program it only creates one batch and then runs it. Mabey you could send me the program, and a couple of small *.wp files, so I can test it myself. In the meantime, here's the script with a GetShortName( ) function = added. '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' Dim oFSO, oShell Dim aCmdArgs Dim sTempBatFile, sShortName, sBaseName, sCmdline Dim hDestFile, oDestTextStream Set oFSO=3DCreateObject("Scripting.FileSystemObject") Set oShell =3D wscript.CreateObject("WScript.Shell") Const TEMP_DIR=3D2 Const WRITE_ONLY=3D2 Const ASCII=3D0 Set aCmdArgs=3Dwscript.arguments If aCmdArgs.count 0 Then sTempBatFile =3D oFSO.GetSpecialFolder(TEMP_DIR) & "\" & = oFSO.GetBaseName(oFSO.GetTempName) & ".bat" oFSO.CreateTextFile sTempBatFile Set hDestFile=3DoFSO.GetFile(sTempBatFile) Set oDestTextStream=3DhDestFile.OpenAsTextStream(WRITE _ONLY,ASCII) oDestTextStream.WriteLine("@echo off") For Each x In aCmdArgs sShortName =3D GetShortName(x) sBaseName =3D oFSO.GetBaseName(sShortName) sCmdline=3D"pre602.exe /d:5 "+sShortName+" "+sBaseName+".602" oDestTextStream.WriteLine(sCmdline) Next oDestTextStream.WriteLine("pause") oDestTextStream.WriteLine("cls") oDestTextStream.Close oShell.Run sTempBatFile,,TRUE oFSO.DeleteFile(sTempBatFile) End If wscript.quit Function GetShortName(filespec) Dim f Set f =3D oFSO.GetFile(filespec) GetShortName =3D f.ShortName End Function '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''' "Ivan B=FAtora" wrote in message = ... Hi again, well, I can generally see OK now, so I'm back (somewhat). Thanks for = your response. I understand that there is no easy way to refer to a file name without the path in explorer. As for the script, it does create the .bat files in %temp%, but it = creates a separate .bat file for each selected .wp file rather than one .bat file with everything in it. Also, is it possible to = substitute long file names with 8.3 file names - pre602.exe doesn't understand long file names. Thanks, Ivan "Bill Blanton" wrote in message = ... Is the called program (pre602.exe ) a window's program? That is = about the only explanation assuming everything is configured correctly. = The script simply builds a batch file and launches it. If you want to = examine the batch file, then comment out the line that deletes the = temporary batch file and look at it (in %temp%.) It will something look like this- @echo off pre602.exe /d:5 file1.wp file1.602 pre602.exe /d:5 file2.wp file2.602 pre602.exe /d:5 file3.wp file3.602 pause cls =20 |
#28
|
|||
|
|||
running many files through the same command
On Fri, 9 Jul 2004 13:57:29 +0200, Ivan Bútora, wrote:
Also, what does %* mean when it's used in a similar context as %1? Is there a web page somewhere where one can read all about the possibilities for explorer file manipulation? I don't know where that comes from. If you load DOSKEY, which comes with 98SE, you can use $* to pass the entire parameter list as one variable. I've subscribed to this group only a few days ago, so I'm missing the original question at the start of the thread. Are you aware that stuff like... dir /b *.wp x.bat dir /b /s *.wp y.bat ....will give you a clean listing of files? Then you can go in with EDIT or NOTEPAD. For the string "C:" substitute "C:\path\program.exe C:", and you will have a functional BAT file that will work on the target files one at a time. -- Walter Dnes; my email address is *ALMOST* like Delete the "z" to get my real address. If that gets blocked, follow the instructions at the end of the 550 message. |
#29
|
|||
|
|||
running many files through the same command
I also missed the original posting but there's also the DOS command
for %i in (*.*) do "something" which passes each file in current directory one at a time to the program (or batch file etc.) "something" "Walter Dnes (delete the 'z' to get my real address)" wrote in message ... On Fri, 9 Jul 2004 13:57:29 +0200, Ivan Bútora, wrote: Also, what does %* mean when it's used in a similar context as %1? Is there a web page somewhere where one can read all about the possibilities for explorer file manipulation? I don't know where that comes from. If you load DOSKEY, which comes with 98SE, you can use $* to pass the entire parameter list as one variable. I've subscribed to this group only a few days ago, so I'm missing the original question at the start of the thread. Are you aware that stuff like... dir /b *.wp x.bat dir /b /s *.wp y.bat ...will give you a clean listing of files? Then you can go in with EDIT or NOTEPAD. For the string "C:" substitute "C:\path\program.exe C:", and you will have a functional BAT file that will work on the target files one at a time. -- Walter Dnes; my email address is *ALMOST* like Delete the "z" to get my real address. If that gets blocked, follow the instructions at the end of the 550 message. |
#30
|
|||
|
|||
running many files through the same command
IOW, the send to function basically passes the all the arguments
at once to the program. Using the reg's "shell\open\command\progname.exe "%1"" method passes each file one at a time on a new commandline. Yes, the full paths to the files needs to be specified or do a CD at the top of the bat. The first method, which I use below, has the added benefit of being able to use it across folders (i.e. in the "find" window). Change the constant ********PROG_DIR to reflect the full directory path\ to pre602.exe ''''''''''''''''''''''''''''''''''''''''''''''' Dim oFSO, oShell Dim aCmdArgs Dim oFile, oFolder Dim sTempBatFile, sShortDir, s602Name, sCmdline Dim hDestFile, oDestTextStream Const TEMP_DIR=2 Const WRITE_ONLY=2 Const ASCII=0 '*************** Const PROG_DIR="D:\TEMP\CONVER~1\" ' dir name must have trailing \ '*************** Set oFSO=CreateObject("Scripting.FileSystemObject") Set oShell=wscript.CreateObject("WScript.Shell") Set aCmdArgs=wscript.arguments If aCmdArgs.count 0 Then sTempBatFile=oFSO.GetSpecialFolder(TEMP_DIR) & "\" & oFSO.GetBaseName(oFSO.GetTempName) & ".bat" oFSO.CreateTextFile sTempBatFile Set hDestFile=oFSO.GetFile(sTempBatFile) Set oDestTextStream=hDestFile.OpenAsTextStream(WRITE_O NLY,ASCII) oDestTextStream.WriteLine("@echo off") For Each x In aCmdArgs Set oFile=oFSO.GetFile(x) Set oFolder=oFSO.GetFolder(oFile.ParentFolder) sShortDir=oFolder.ShortPath If Not oFolder.IsRootFolder Then sShortDir=sShortDir + "\" End If s602Name=sShortDir + oFSO.GetBaseName(oFile.ShortName) + ".602" sCmdline=PROG_DIR + "pre602.exe /d:5" + " " + oFile.ShortPath + " " + s602Name oDestTextStream.WriteLine("echo" + " " + sCmdline) 'remove to not echo the command line oDestTextStream.WriteLine(sCmdline) oDestTextStream.WriteLine("echo.") Next oDestTextStream.WriteLine("pause") 'remove to not have to close window oDestTextStream.WriteLine("cls") oDestTextStream.Close oShell.Run sTempBatFile,,TRUE oFSO.DeleteFile(sTempBatFile) End If wscript.quit ''''''''''''''''''''''''''''''''''''''''''''''' "Ivan Bútora" wrote in message ... I must admit that I don't quite understand where the accumulation of arguments actually happens, and how the send to menu is distinctive in this sense - but I guess I would have to understand the actually script in order to get a good sense of what's going on. Anyway, I did create a shortcut to convert.vbs in C:\Windows\SendTo, and now it indeed just creates one batch file, but gives the errors that you mentioned. Those errors indeed mean "file (...) not found" in Czech. Is the issue now the full path to the files that we want to convert? Thanks for your help with this, Ivan |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Recovering files | DAJ | General | 3 | June 21st 04 05:39 AM |
C Windows profiles user application data | LuckyStrike | General | 24 | June 18th 04 12:13 AM |
Lost access to Windows Help Files | overzealous | General | 2 | June 14th 04 10:08 PM |
Safely delete .exe files in "TEMP" folder?? | CNJ | General | 2 | June 14th 04 06:16 AM |
Question about C:\Windows\Temp files | JR Berry | General | 6 | June 7th 04 09:32 PM |