# Handle files into sub-folders having the same parent in batc

April 15, 2013 at 12:01:20
Specs: Windows 7
 I run mybat.bat whose path is D:\path\to\my\data.the "data" folder, that is my current directory, contains two folders namely "data1" and "data2". data1 contains file1.txt and data2 also contains file1 with another extension file name (file1.out)I am at the current directory data where mybat.bat is being run.I would pass the "file1.txt" and "file1.out" to a "tamo.bat", knowing that "tamo.bat" is the same directory as "mybat.bat" (the "data" directory) .Here's I write, but it doesn't work! SET mypath=%~dp0 set var=file1 set getTXTBySubPath=%mypath%data1\%var%.txt echo -----getTXTBySubPath----- set getOUTBySubPath=%mypath%data2\%var%.out Call tamo.bat %getTXTBySubPath% %getOUTBySubPath%Please how could I achieve that ? Thanks

See More: Handle files into sub-folders having the same parent in batc

#1
April 15, 2013 at 12:22:14
 CALL tamo data1\file1.txt data2\file1.out

Report •

#2
April 15, 2013 at 13:04:07
 Using what you suggest, i try it out doing echo "%1" echo "%2" in tamo.bat and it results in error....There is the error message:(I think it means files does not find)D:\path\to\my\data.>mybat.bat"file1.txt"""data1\file1.TXT""""data2\file1.out""Microsoft (R) Windows Script Host Version 5.8Copyright (C) Microsoft Corporation 1996-2001. Tous droits réservés.D:\path\to\my\data\code.vbs(86, 2) Erreur d'exécution Microsoft VBScript: Fichier introuvable

Report •

#3
April 15, 2013 at 13:56:19
 I'd have to see the scripts, but that looks like an excessive amount of double quotes.

Report •

Related Solutions

#4
April 16, 2013 at 02:06:02
 Here's tamo.bat. Indeed, it calls a vbs code namely code.vbs where each parameter of code.vbs is a file, the first one is "file1.txt" and the second one is "file1.out" which is coming from mybat.batset first="%1"set second="%2"echo %first%echo %second%cscript code.vbs /x:%first% /y:%second%code.vbs in turns get the first parameter like that dim paramvbs: paramvbs=Wscript.Arguments.Named("x")which is used for running a shell:shell.run "another.bat """ & paramvbs & """ ""file.out"""I think that the parameters of code.vbs causes error while calling 'another.bat', I don't know why and how to fix it. Thank you your help.

Report •

#5
April 16, 2013 at 04:19:13
 I try a test with real values on calling code.vbs from tamo.bat like thiscscript code.vbs /x:"data1\my file 1.txt" /y:"data2\my file 1.out"I notice that paramvbs: paramvbs=Wscript.Arguments.Named("x")which is used for running a shell:shell.run "another.bat """ & paramvbs & """ ""file.out"""causes problem,therefore shell does not run....Thanks

Report •

#6
April 16, 2013 at 07:32:43
 Yeah, you seem to be tripping over the double quotes pretty hard.Batch doesn't bother to strip out double quotes, so you don't need to add them if you're just passing them along. If you're using the arguments in your script, you can strip the double quotes out by using the %~1 syntax. In this instance you're not, so you don't have to.cscript code.vbs /x:%1 /y:%2VBScript does strip out double quotes, so if you're building a command line, you'll need to add them as appropriate, which you seem to be doing, unless you're further modifying that paramvbs variable.

Report •