How to execute a Batchfile in a folder, by dropping the folder on the file
up vote
0
down vote
favorite
I have a small batch file that executes a few simple lines of code.
It works perfectly fine when I put it in the Folder and execute it.
However the file should be located on level above it and be able to get executed by having the folder being droped on to it.
When I currently drop the folder on to it, it just executes the code as if I would just double click it. However it should behave as if the file was located inside the folder.
@echo off
for %%a in (*.*) do @echo %%~na >> filenames.txt
)
pause
How would I do that?
I don't want to apply it to every folder just the one chosen by dropping it onto the file.
I want to generate a file from all the filenames inside the Folder.
which will then be compared to an other file created from an other folder.
@echo off
echo new additions > test3.txt
findstr /vixg:shots.txt shots2.txt >> test3.txt
echo removed >> test3.txt
findstr /vixg:shots2.txt shots.txt >> test3.txt
I assume I can|t automate the comparison, by dropping two folders onto the file, can I?
batch-file
add a comment |
up vote
0
down vote
favorite
I have a small batch file that executes a few simple lines of code.
It works perfectly fine when I put it in the Folder and execute it.
However the file should be located on level above it and be able to get executed by having the folder being droped on to it.
When I currently drop the folder on to it, it just executes the code as if I would just double click it. However it should behave as if the file was located inside the folder.
@echo off
for %%a in (*.*) do @echo %%~na >> filenames.txt
)
pause
How would I do that?
I don't want to apply it to every folder just the one chosen by dropping it onto the file.
I want to generate a file from all the filenames inside the Folder.
which will then be compared to an other file created from an other folder.
@echo off
echo new additions > test3.txt
findstr /vixg:shots.txt shots2.txt >> test3.txt
echo removed >> test3.txt
findstr /vixg:shots2.txt shots.txt >> test3.txt
I assume I can|t automate the comparison, by dropping two folders onto the file, can I?
batch-file
So.. how about posting the code of your batch file so we can see it and actually help you?
– Gerhard Barnard
Nov 8 at 11:35
thanks for the imput
– Frezzley
Nov 8 at 11:42
When dropping elements on another batch/script/exe they get passed as command line arguments, receivable in batch with%1
to%9
(or as %1 and looped with a shift in between). So it is possible, but you show fixed file names and expect ever changing file/folder names to be accessed how?
– LotPings
Nov 8 at 11:59
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a small batch file that executes a few simple lines of code.
It works perfectly fine when I put it in the Folder and execute it.
However the file should be located on level above it and be able to get executed by having the folder being droped on to it.
When I currently drop the folder on to it, it just executes the code as if I would just double click it. However it should behave as if the file was located inside the folder.
@echo off
for %%a in (*.*) do @echo %%~na >> filenames.txt
)
pause
How would I do that?
I don't want to apply it to every folder just the one chosen by dropping it onto the file.
I want to generate a file from all the filenames inside the Folder.
which will then be compared to an other file created from an other folder.
@echo off
echo new additions > test3.txt
findstr /vixg:shots.txt shots2.txt >> test3.txt
echo removed >> test3.txt
findstr /vixg:shots2.txt shots.txt >> test3.txt
I assume I can|t automate the comparison, by dropping two folders onto the file, can I?
batch-file
I have a small batch file that executes a few simple lines of code.
It works perfectly fine when I put it in the Folder and execute it.
However the file should be located on level above it and be able to get executed by having the folder being droped on to it.
When I currently drop the folder on to it, it just executes the code as if I would just double click it. However it should behave as if the file was located inside the folder.
@echo off
for %%a in (*.*) do @echo %%~na >> filenames.txt
)
pause
How would I do that?
I don't want to apply it to every folder just the one chosen by dropping it onto the file.
I want to generate a file from all the filenames inside the Folder.
which will then be compared to an other file created from an other folder.
@echo off
echo new additions > test3.txt
findstr /vixg:shots.txt shots2.txt >> test3.txt
echo removed >> test3.txt
findstr /vixg:shots2.txt shots.txt >> test3.txt
I assume I can|t automate the comparison, by dropping two folders onto the file, can I?
batch-file
batch-file
edited Nov 8 at 11:42
asked Nov 8 at 11:19
Frezzley
125112
125112
So.. how about posting the code of your batch file so we can see it and actually help you?
– Gerhard Barnard
Nov 8 at 11:35
thanks for the imput
– Frezzley
Nov 8 at 11:42
When dropping elements on another batch/script/exe they get passed as command line arguments, receivable in batch with%1
to%9
(or as %1 and looped with a shift in between). So it is possible, but you show fixed file names and expect ever changing file/folder names to be accessed how?
– LotPings
Nov 8 at 11:59
add a comment |
So.. how about posting the code of your batch file so we can see it and actually help you?
– Gerhard Barnard
Nov 8 at 11:35
thanks for the imput
– Frezzley
Nov 8 at 11:42
When dropping elements on another batch/script/exe they get passed as command line arguments, receivable in batch with%1
to%9
(or as %1 and looped with a shift in between). So it is possible, but you show fixed file names and expect ever changing file/folder names to be accessed how?
– LotPings
Nov 8 at 11:59
So.. how about posting the code of your batch file so we can see it and actually help you?
– Gerhard Barnard
Nov 8 at 11:35
So.. how about posting the code of your batch file so we can see it and actually help you?
– Gerhard Barnard
Nov 8 at 11:35
thanks for the imput
– Frezzley
Nov 8 at 11:42
thanks for the imput
– Frezzley
Nov 8 at 11:42
When dropping elements on another batch/script/exe they get passed as command line arguments, receivable in batch with
%1
to %9
(or as %1 and looped with a shift in between). So it is possible, but you show fixed file names and expect ever changing file/folder names to be accessed how?– LotPings
Nov 8 at 11:59
When dropping elements on another batch/script/exe they get passed as command line arguments, receivable in batch with
%1
to %9
(or as %1 and looped with a shift in between). So it is possible, but you show fixed file names and expect ever changing file/folder names to be accessed how?– LotPings
Nov 8 at 11:59
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
I am not 100% sure what you want, but I am assuming you want to match shots.txt
which is in folder1
with shots2.txt
in folder2
. Something like this should work if that is the case:
@echo off
echo new additions > test3.txt
if exist "%1shots.txt" (findstr /vixg:"%1shots.txt" "%2shots2.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots.txt" "%1shots2.txt" >> test3.txt)
echo removed >> test3.txt
if exist "%1shots2.txt" (findstr /vixg:"%1shots2.txt" "%2shots.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots2.txt" "%1shots.txt" >> test3.txt)
You can then select 2 folders containing the files and drop them both onto the batch file.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I am not 100% sure what you want, but I am assuming you want to match shots.txt
which is in folder1
with shots2.txt
in folder2
. Something like this should work if that is the case:
@echo off
echo new additions > test3.txt
if exist "%1shots.txt" (findstr /vixg:"%1shots.txt" "%2shots2.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots.txt" "%1shots2.txt" >> test3.txt)
echo removed >> test3.txt
if exist "%1shots2.txt" (findstr /vixg:"%1shots2.txt" "%2shots.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots2.txt" "%1shots.txt" >> test3.txt)
You can then select 2 folders containing the files and drop them both onto the batch file.
add a comment |
up vote
1
down vote
I am not 100% sure what you want, but I am assuming you want to match shots.txt
which is in folder1
with shots2.txt
in folder2
. Something like this should work if that is the case:
@echo off
echo new additions > test3.txt
if exist "%1shots.txt" (findstr /vixg:"%1shots.txt" "%2shots2.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots.txt" "%1shots2.txt" >> test3.txt)
echo removed >> test3.txt
if exist "%1shots2.txt" (findstr /vixg:"%1shots2.txt" "%2shots.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots2.txt" "%1shots.txt" >> test3.txt)
You can then select 2 folders containing the files and drop them both onto the batch file.
add a comment |
up vote
1
down vote
up vote
1
down vote
I am not 100% sure what you want, but I am assuming you want to match shots.txt
which is in folder1
with shots2.txt
in folder2
. Something like this should work if that is the case:
@echo off
echo new additions > test3.txt
if exist "%1shots.txt" (findstr /vixg:"%1shots.txt" "%2shots2.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots.txt" "%1shots2.txt" >> test3.txt)
echo removed >> test3.txt
if exist "%1shots2.txt" (findstr /vixg:"%1shots2.txt" "%2shots.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots2.txt" "%1shots.txt" >> test3.txt)
You can then select 2 folders containing the files and drop them both onto the batch file.
I am not 100% sure what you want, but I am assuming you want to match shots.txt
which is in folder1
with shots2.txt
in folder2
. Something like this should work if that is the case:
@echo off
echo new additions > test3.txt
if exist "%1shots.txt" (findstr /vixg:"%1shots.txt" "%2shots2.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots.txt" "%1shots2.txt" >> test3.txt)
echo removed >> test3.txt
if exist "%1shots2.txt" (findstr /vixg:"%1shots2.txt" "%2shots.txt" >> test3.txt)
if exist "%2shots.txt" (findstr /vixg:"%2shots2.txt" "%1shots.txt" >> test3.txt)
You can then select 2 folders containing the files and drop them both onto the batch file.
answered Nov 8 at 12:40
Gerhard Barnard
6,45531130
6,45531130
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206708%2fhow-to-execute-a-batchfile-in-a-folder-by-dropping-the-folder-on-the-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
So.. how about posting the code of your batch file so we can see it and actually help you?
– Gerhard Barnard
Nov 8 at 11:35
thanks for the imput
– Frezzley
Nov 8 at 11:42
When dropping elements on another batch/script/exe they get passed as command line arguments, receivable in batch with
%1
to%9
(or as %1 and looped with a shift in between). So it is possible, but you show fixed file names and expect ever changing file/folder names to be accessed how?– LotPings
Nov 8 at 11:59