HI
i have the following behaviour!! when dragging an input file to a BATCH file.
when using sort %1 >>out.txt ,the output file does not appear in the working directory ,however,if i use the command : type out.txt there is an output.
@echo off
sort %1 >>f4.txt //No output file APPEARS in the current directory
type f4.txt // there is a correct output
pause
PLease Why ?
dragging input file to batch
Moderator: DosItHelp
Re: dragging input file to batch
'
Test this:
Test this:
Code: Select all
@echo off
echo.
echo.working directory: '%CD%'
> "ou.TMP" echo.This Works
if exist "ou.TMP" (
echo. file exists in working directory: '%CD%'
)
del /f /q "ou.TMP"
pause
exit /b 0
Re: dragging input file to batch
I tried it
I conclude the following:
-When running the file normaly(NO drag input file) ,the working directory is the folder you created the batch file in:
eg: "c:\documents and settings\administrator\desktop\new folder"
-When dragging the input file to the batch,the working directory is:
"c:\documents and settings\administrator"
I want all my files due to >> or > redirection to be written to the current directory in which the batch is running,
i used >>"%~dp0\output.txt" and >"%~dp0\output.txt"
this is working well.
Thank you
I conclude the following:
-When running the file normaly(NO drag input file) ,the working directory is the folder you created the batch file in:
eg: "c:\documents and settings\administrator\desktop\new folder"
-When dragging the input file to the batch,the working directory is:
"c:\documents and settings\administrator"
I want all my files due to >> or > redirection to be written to the current directory in which the batch is running,
i used >>"%~dp0\output.txt" and >"%~dp0\output.txt"
this is working well.
Thank you
Re: dragging input file to batch
'
Did you know you can push &pop dirs ?
or without going back:
Did you know you can push &pop dirs ?
Code: Select all
pushd "%~dp0\"
::(
echo.do things here :)
::)
popd
Code: Select all
cd "%~dp0\"
Re: dragging input file to batch
I didn't use it before .
Thank you very much !
Thank you very much !