I'm creating a script that creates a file inside the current directory.
@echo off
set /p file= filename and extension:
echo something_test >> %file%
But, let's say the current directory is this:
INSIDE (fo) main_folder: {
(fi) script.bat
(fo) somefolder
}
(fi = file and fo = folder; script.bat is the script I'm making)
If I run the script and input file.txt, (fi) file.txt will be created in (fi) script.bat's main directory ((fo) main_folder).
Now let's say I want to create it inside (fo) somefolder.
The obvious thing would be to do this:
@echo off
cd somefolder
set /p file= filename and extension:
echo something_test >> %file%
Then; If I run the script and input file.txt, (fi) file.txt will be created in (fi) script.bat's WORKING directory ((fo) somefolder).
But what I want to do is to, just by inputing into the set /p command, create the file in (fo) somefolder, without using the cd command.
And how to, just by inputing into the set /p command, create the file in (fo) main_folder's main directory, without using the cd.. command?
@(Echo something_test)>>"%~dp0somefolder\%file%"would seem too obvious to me, so perhaps there's something you haven't explained properly to us.(echo something)>>"..\%file%"for the last paragraph. So I too think the explanation is not sufficient.%CD%,@(Echo something_test)>>"%CD%\somefolder\%file%"or%__CD__%,@(Echo something_test)>>"%__CD__%somefolder\%file%"too.