IIRC we had some issue(s) with running a batch file as a "post-processing command", but I think it had to do with passing parameters into the batch file. I know I have the conversation archived, so I may be able to dig it up and summarize it here. From my memory, I think we never resolved the problem and decided that in certain situations the user should write a simple JScript/Perl/Python/Ruby/VBScript script that executes the commands using the passed parameters.
Back to the current "Run in directory" issue...A simple test
In the simplest scenario I could devise, running a batch file with a specified "Run in directory" value seems to work correctly for me.
Create a helloworld.bat
file that contains the following lines:
Code: Select all
echo hello world > helloworld.txt
In these tests I did not use "cmd /c" or "cmd /c start".
Running this batch file as a "post-processing command" without specifying a "Run in directory" creates the helloworld.txt file in the same directory as Awasu.exe.
Running this batch file as a "post-processing command" specifying a "Run in directory" creates the helloworld.txt file in the directory specified by the "Run in directory" field.One step up the evolutionary chain
My tests with a multiple command batch file like yours yielded the same results; only the first command seemed to execute. So I experimented by placing each command on the same line separated by the "command separator" (&&) and it seems to work. I know this "ain't purdy" as we say in "the states", but it looks like it'll work.Note:
I had a problems running your exact script. I don't have iconv.exe and I'm not a sed.exe expert so I made a simple Windows batch file that looks for lines containing "html" in the input file and echos them on to the output file.
Code: Select all
REM Ignore the line wrapping this is really all on one line:
findstr "html" < file_1.txt > file_2.txt && findstr "html" < file_2.txt > file_3.txt && findstr "html" < file_3.txt > file_4.txt && findstr "html" < file_4.txt > file_5.txt && findstr "html" < file_5.txt > file_6.txt
When run as a "post-processing command" with a specified a "Run in directory" all 6 files are created. File_1.txt contains the full Channel Report text while files 2-6 contain only the lines that contain the "html" substring.
Even though this seems to work I still receive an error message when I check the return code: The external command failed: return code 255
Prefixing the "post-processing command" with "cmd /c" yields the same results as above while prefixing with "cmd /k" yields: The external command failed: return code 1Maybe
one of the lines is returning an error code and somehow CreateProcess() grabs it and exits, and maybe
by making it a one-liner the error code doesn't get returned until the whole line executes
Finally, regarding the previous suggestion of putting a CD at the start of your batch file, many people don't know that, within batch files only
, there is an environment variable named %CD%
that contains current directory. Don't bother looking for it at the command prompt using the SET
command, you won't find it, but you can echo %CD% > test_file.txt
to see that %CD% exists. So maybe you could prefix your file names with either .\file_1.txt