How to get filename only without path in windows command line?
for /r %f in (*) do echo %f
Gives the output filename along with the entire path
pathtodir<filename>
How do i get just the <filename>
without the path included? I need to use that 'filename' string.
Also, is it possible to do the following, once the filename is acquired?
for /r %%f in (*) do (
echo "blah blah blah 'filename'" >> blahblah_filename.txt
)
windows command-line script batch
add a comment |
for /r %f in (*) do echo %f
Gives the output filename along with the entire path
pathtodir<filename>
How do i get just the <filename>
without the path included? I need to use that 'filename' string.
Also, is it possible to do the following, once the filename is acquired?
for /r %%f in (*) do (
echo "blah blah blah 'filename'" >> blahblah_filename.txt
)
windows command-line script batch
2
For future reference, Microsoft has an online Windows XP - Command-line reference A-Z which is still mostly applicable to later versions. The documentation in the answer you accepted is at the end of the section on thefor
command.
– martineau
Oct 18 '12 at 3:31
@martineau: Unfortunately, the online 'Windows XP - Command-line reference A-Z' page is no longer on-line (removed by microsoft) and an alternative for this documentation is not yet available (as far as I can find any codumentation on '%~' argument documentation)
– PapaAtHome
Jul 2 '18 at 9:08
@PapaAtHome: Fortunately one can still view the command line reference via web.archive.org's wayback machine.
– martineau
Jul 2 '18 at 12:36
add a comment |
for /r %f in (*) do echo %f
Gives the output filename along with the entire path
pathtodir<filename>
How do i get just the <filename>
without the path included? I need to use that 'filename' string.
Also, is it possible to do the following, once the filename is acquired?
for /r %%f in (*) do (
echo "blah blah blah 'filename'" >> blahblah_filename.txt
)
windows command-line script batch
for /r %f in (*) do echo %f
Gives the output filename along with the entire path
pathtodir<filename>
How do i get just the <filename>
without the path included? I need to use that 'filename' string.
Also, is it possible to do the following, once the filename is acquired?
for /r %%f in (*) do (
echo "blah blah blah 'filename'" >> blahblah_filename.txt
)
windows command-line script batch
windows command-line script batch
asked Oct 18 '12 at 2:44
Jay
56341123
56341123
2
For future reference, Microsoft has an online Windows XP - Command-line reference A-Z which is still mostly applicable to later versions. The documentation in the answer you accepted is at the end of the section on thefor
command.
– martineau
Oct 18 '12 at 3:31
@martineau: Unfortunately, the online 'Windows XP - Command-line reference A-Z' page is no longer on-line (removed by microsoft) and an alternative for this documentation is not yet available (as far as I can find any codumentation on '%~' argument documentation)
– PapaAtHome
Jul 2 '18 at 9:08
@PapaAtHome: Fortunately one can still view the command line reference via web.archive.org's wayback machine.
– martineau
Jul 2 '18 at 12:36
add a comment |
2
For future reference, Microsoft has an online Windows XP - Command-line reference A-Z which is still mostly applicable to later versions. The documentation in the answer you accepted is at the end of the section on thefor
command.
– martineau
Oct 18 '12 at 3:31
@martineau: Unfortunately, the online 'Windows XP - Command-line reference A-Z' page is no longer on-line (removed by microsoft) and an alternative for this documentation is not yet available (as far as I can find any codumentation on '%~' argument documentation)
– PapaAtHome
Jul 2 '18 at 9:08
@PapaAtHome: Fortunately one can still view the command line reference via web.archive.org's wayback machine.
– martineau
Jul 2 '18 at 12:36
2
2
For future reference, Microsoft has an online Windows XP - Command-line reference A-Z which is still mostly applicable to later versions. The documentation in the answer you accepted is at the end of the section on the
for
command.– martineau
Oct 18 '12 at 3:31
For future reference, Microsoft has an online Windows XP - Command-line reference A-Z which is still mostly applicable to later versions. The documentation in the answer you accepted is at the end of the section on the
for
command.– martineau
Oct 18 '12 at 3:31
@martineau: Unfortunately, the online 'Windows XP - Command-line reference A-Z' page is no longer on-line (removed by microsoft) and an alternative for this documentation is not yet available (as far as I can find any codumentation on '%~' argument documentation)
– PapaAtHome
Jul 2 '18 at 9:08
@martineau: Unfortunately, the online 'Windows XP - Command-line reference A-Z' page is no longer on-line (removed by microsoft) and an alternative for this documentation is not yet available (as far as I can find any codumentation on '%~' argument documentation)
– PapaAtHome
Jul 2 '18 at 9:08
@PapaAtHome: Fortunately one can still view the command line reference via web.archive.org's wayback machine.
– martineau
Jul 2 '18 at 12:36
@PapaAtHome: Fortunately one can still view the command line reference via web.archive.org's wayback machine.
– martineau
Jul 2 '18 at 12:36
add a comment |
2 Answers
2
active
oldest
votes
Use %~nxf
for <filename>.<extension>
.
And yes, you can do:
for /r %%f in (*) do (
echo "blah blah blah '%%~nxf'" >> blahblah_%%~nxf.txt
)
See for /?
:
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
The modifiers can be combined to get compound results:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line
In the above examples %I and PATH can be replaced by other valid
values. The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.
Great answer. Any idea how I could search for a substring in a full path? For example, I want to know if c:codemyapp.gitsomefolder includes the text ".git".
– Dale Barnard
Nov 3 '16 at 20:46
1
You can perform a textual or regex search by piping the path into thefind
orfindstr
command, e.g.echo %%f | find ".git" > NUL
orecho %%f | findstr /R /C:"\.git\" /C:"\.git>" > NUL
and then checking the errorlevel with theif
command. (findstr regex is very limited, so that's my attempt at enforcing a leadingand [either a trailing
or end of string]). Do note that
if errorlevel
has quirks with fall-through, and you probably can'tif %errorlevel%
within a loop so you might need toSetLocal EnableDelayedExpansion
first and thenif !errorlevel!
instead.
– Bob
Nov 3 '16 at 23:24
@DaleBarnard Also, consider using PowerShell - much much less pain and probably more consistent results.
– Bob
Nov 3 '16 at 23:24
The blah blah is confusing me, what is it supposed to represent? How does the full path of the file and the extracted file name fit into this answer?
– thebunnyrules
Apr 28 '17 at 16:38
@thebunnyrules%~nxf
is the filename, as I said in the first sentence. When you use it within a batch file, you need to double up the%
, making it%%~nxf
. Theblah blah blah
is just taking the example in the question and replacing thefilename
bit with the%%~nxf
substitution - theblah
s are just filler and have no particular meaning.
– Bob
Apr 28 '17 at 16:51
|
show 1 more comment
I'm not yet able to comment, but I believe the following should be noted to avoid confusion.
While f
can be used as a FOR variable name, it's best to use another letter to avoid confusing it with format letter f
(which, as stated in Bob's answer, returns full path name), or at least use a capital F
.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2fsuperuser.com%2fquestions%2f489240%2fhow-to-get-filename-only-without-path-in-windows-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use %~nxf
for <filename>.<extension>
.
And yes, you can do:
for /r %%f in (*) do (
echo "blah blah blah '%%~nxf'" >> blahblah_%%~nxf.txt
)
See for /?
:
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
The modifiers can be combined to get compound results:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line
In the above examples %I and PATH can be replaced by other valid
values. The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.
Great answer. Any idea how I could search for a substring in a full path? For example, I want to know if c:codemyapp.gitsomefolder includes the text ".git".
– Dale Barnard
Nov 3 '16 at 20:46
1
You can perform a textual or regex search by piping the path into thefind
orfindstr
command, e.g.echo %%f | find ".git" > NUL
orecho %%f | findstr /R /C:"\.git\" /C:"\.git>" > NUL
and then checking the errorlevel with theif
command. (findstr regex is very limited, so that's my attempt at enforcing a leadingand [either a trailing
or end of string]). Do note that
if errorlevel
has quirks with fall-through, and you probably can'tif %errorlevel%
within a loop so you might need toSetLocal EnableDelayedExpansion
first and thenif !errorlevel!
instead.
– Bob
Nov 3 '16 at 23:24
@DaleBarnard Also, consider using PowerShell - much much less pain and probably more consistent results.
– Bob
Nov 3 '16 at 23:24
The blah blah is confusing me, what is it supposed to represent? How does the full path of the file and the extracted file name fit into this answer?
– thebunnyrules
Apr 28 '17 at 16:38
@thebunnyrules%~nxf
is the filename, as I said in the first sentence. When you use it within a batch file, you need to double up the%
, making it%%~nxf
. Theblah blah blah
is just taking the example in the question and replacing thefilename
bit with the%%~nxf
substitution - theblah
s are just filler and have no particular meaning.
– Bob
Apr 28 '17 at 16:51
|
show 1 more comment
Use %~nxf
for <filename>.<extension>
.
And yes, you can do:
for /r %%f in (*) do (
echo "blah blah blah '%%~nxf'" >> blahblah_%%~nxf.txt
)
See for /?
:
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
The modifiers can be combined to get compound results:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line
In the above examples %I and PATH can be replaced by other valid
values. The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.
Great answer. Any idea how I could search for a substring in a full path? For example, I want to know if c:codemyapp.gitsomefolder includes the text ".git".
– Dale Barnard
Nov 3 '16 at 20:46
1
You can perform a textual or regex search by piping the path into thefind
orfindstr
command, e.g.echo %%f | find ".git" > NUL
orecho %%f | findstr /R /C:"\.git\" /C:"\.git>" > NUL
and then checking the errorlevel with theif
command. (findstr regex is very limited, so that's my attempt at enforcing a leadingand [either a trailing
or end of string]). Do note that
if errorlevel
has quirks with fall-through, and you probably can'tif %errorlevel%
within a loop so you might need toSetLocal EnableDelayedExpansion
first and thenif !errorlevel!
instead.
– Bob
Nov 3 '16 at 23:24
@DaleBarnard Also, consider using PowerShell - much much less pain and probably more consistent results.
– Bob
Nov 3 '16 at 23:24
The blah blah is confusing me, what is it supposed to represent? How does the full path of the file and the extracted file name fit into this answer?
– thebunnyrules
Apr 28 '17 at 16:38
@thebunnyrules%~nxf
is the filename, as I said in the first sentence. When you use it within a batch file, you need to double up the%
, making it%%~nxf
. Theblah blah blah
is just taking the example in the question and replacing thefilename
bit with the%%~nxf
substitution - theblah
s are just filler and have no particular meaning.
– Bob
Apr 28 '17 at 16:51
|
show 1 more comment
Use %~nxf
for <filename>.<extension>
.
And yes, you can do:
for /r %%f in (*) do (
echo "blah blah blah '%%~nxf'" >> blahblah_%%~nxf.txt
)
See for /?
:
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
The modifiers can be combined to get compound results:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line
In the above examples %I and PATH can be replaced by other valid
values. The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.
Use %~nxf
for <filename>.<extension>
.
And yes, you can do:
for /r %%f in (*) do (
echo "blah blah blah '%%~nxf'" >> blahblah_%%~nxf.txt
)
See for /?
:
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories listed in the PATH
environment variable and expands %I to the
fully qualified name of the first one found.
If the environment variable name is not
defined or the file is not found by the
search, then this modifier expands to the
empty string
The modifiers can be combined to get compound results:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line
In the above examples %I and PATH can be replaced by other valid
values. The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.
answered Oct 18 '12 at 3:00
Bob
45.4k20137172
45.4k20137172
Great answer. Any idea how I could search for a substring in a full path? For example, I want to know if c:codemyapp.gitsomefolder includes the text ".git".
– Dale Barnard
Nov 3 '16 at 20:46
1
You can perform a textual or regex search by piping the path into thefind
orfindstr
command, e.g.echo %%f | find ".git" > NUL
orecho %%f | findstr /R /C:"\.git\" /C:"\.git>" > NUL
and then checking the errorlevel with theif
command. (findstr regex is very limited, so that's my attempt at enforcing a leadingand [either a trailing
or end of string]). Do note that
if errorlevel
has quirks with fall-through, and you probably can'tif %errorlevel%
within a loop so you might need toSetLocal EnableDelayedExpansion
first and thenif !errorlevel!
instead.
– Bob
Nov 3 '16 at 23:24
@DaleBarnard Also, consider using PowerShell - much much less pain and probably more consistent results.
– Bob
Nov 3 '16 at 23:24
The blah blah is confusing me, what is it supposed to represent? How does the full path of the file and the extracted file name fit into this answer?
– thebunnyrules
Apr 28 '17 at 16:38
@thebunnyrules%~nxf
is the filename, as I said in the first sentence. When you use it within a batch file, you need to double up the%
, making it%%~nxf
. Theblah blah blah
is just taking the example in the question and replacing thefilename
bit with the%%~nxf
substitution - theblah
s are just filler and have no particular meaning.
– Bob
Apr 28 '17 at 16:51
|
show 1 more comment
Great answer. Any idea how I could search for a substring in a full path? For example, I want to know if c:codemyapp.gitsomefolder includes the text ".git".
– Dale Barnard
Nov 3 '16 at 20:46
1
You can perform a textual or regex search by piping the path into thefind
orfindstr
command, e.g.echo %%f | find ".git" > NUL
orecho %%f | findstr /R /C:"\.git\" /C:"\.git>" > NUL
and then checking the errorlevel with theif
command. (findstr regex is very limited, so that's my attempt at enforcing a leadingand [either a trailing
or end of string]). Do note that
if errorlevel
has quirks with fall-through, and you probably can'tif %errorlevel%
within a loop so you might need toSetLocal EnableDelayedExpansion
first and thenif !errorlevel!
instead.
– Bob
Nov 3 '16 at 23:24
@DaleBarnard Also, consider using PowerShell - much much less pain and probably more consistent results.
– Bob
Nov 3 '16 at 23:24
The blah blah is confusing me, what is it supposed to represent? How does the full path of the file and the extracted file name fit into this answer?
– thebunnyrules
Apr 28 '17 at 16:38
@thebunnyrules%~nxf
is the filename, as I said in the first sentence. When you use it within a batch file, you need to double up the%
, making it%%~nxf
. Theblah blah blah
is just taking the example in the question and replacing thefilename
bit with the%%~nxf
substitution - theblah
s are just filler and have no particular meaning.
– Bob
Apr 28 '17 at 16:51
Great answer. Any idea how I could search for a substring in a full path? For example, I want to know if c:codemyapp.gitsomefolder includes the text ".git".
– Dale Barnard
Nov 3 '16 at 20:46
Great answer. Any idea how I could search for a substring in a full path? For example, I want to know if c:codemyapp.gitsomefolder includes the text ".git".
– Dale Barnard
Nov 3 '16 at 20:46
1
1
You can perform a textual or regex search by piping the path into the
find
or findstr
command, e.g. echo %%f | find ".git" > NUL
or echo %%f | findstr /R /C:"\.git\" /C:"\.git>" > NUL
and then checking the errorlevel with the if
command. (findstr regex is very limited, so that's my attempt at enforcing a leading
and [either a trailing
or end of string]). Do note that if errorlevel
has quirks with fall-through, and you probably can't if %errorlevel%
within a loop so you might need to SetLocal EnableDelayedExpansion
first and then if !errorlevel!
instead.– Bob
Nov 3 '16 at 23:24
You can perform a textual or regex search by piping the path into the
find
or findstr
command, e.g. echo %%f | find ".git" > NUL
or echo %%f | findstr /R /C:"\.git\" /C:"\.git>" > NUL
and then checking the errorlevel with the if
command. (findstr regex is very limited, so that's my attempt at enforcing a leading
and [either a trailing
or end of string]). Do note that if errorlevel
has quirks with fall-through, and you probably can't if %errorlevel%
within a loop so you might need to SetLocal EnableDelayedExpansion
first and then if !errorlevel!
instead.– Bob
Nov 3 '16 at 23:24
@DaleBarnard Also, consider using PowerShell - much much less pain and probably more consistent results.
– Bob
Nov 3 '16 at 23:24
@DaleBarnard Also, consider using PowerShell - much much less pain and probably more consistent results.
– Bob
Nov 3 '16 at 23:24
The blah blah is confusing me, what is it supposed to represent? How does the full path of the file and the extracted file name fit into this answer?
– thebunnyrules
Apr 28 '17 at 16:38
The blah blah is confusing me, what is it supposed to represent? How does the full path of the file and the extracted file name fit into this answer?
– thebunnyrules
Apr 28 '17 at 16:38
@thebunnyrules
%~nxf
is the filename, as I said in the first sentence. When you use it within a batch file, you need to double up the %
, making it %%~nxf
. The blah blah blah
is just taking the example in the question and replacing the filename
bit with the %%~nxf
substitution - the blah
s are just filler and have no particular meaning.– Bob
Apr 28 '17 at 16:51
@thebunnyrules
%~nxf
is the filename, as I said in the first sentence. When you use it within a batch file, you need to double up the %
, making it %%~nxf
. The blah blah blah
is just taking the example in the question and replacing the filename
bit with the %%~nxf
substitution - the blah
s are just filler and have no particular meaning.– Bob
Apr 28 '17 at 16:51
|
show 1 more comment
I'm not yet able to comment, but I believe the following should be noted to avoid confusion.
While f
can be used as a FOR variable name, it's best to use another letter to avoid confusing it with format letter f
(which, as stated in Bob's answer, returns full path name), or at least use a capital F
.
add a comment |
I'm not yet able to comment, but I believe the following should be noted to avoid confusion.
While f
can be used as a FOR variable name, it's best to use another letter to avoid confusing it with format letter f
(which, as stated in Bob's answer, returns full path name), or at least use a capital F
.
add a comment |
I'm not yet able to comment, but I believe the following should be noted to avoid confusion.
While f
can be used as a FOR variable name, it's best to use another letter to avoid confusing it with format letter f
(which, as stated in Bob's answer, returns full path name), or at least use a capital F
.
I'm not yet able to comment, but I believe the following should be noted to avoid confusion.
While f
can be used as a FOR variable name, it's best to use another letter to avoid confusing it with format letter f
(which, as stated in Bob's answer, returns full path name), or at least use a capital F
.
answered Dec 10 '18 at 8:26
HYBRID BEING
2116
2116
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2fsuperuser.com%2fquestions%2f489240%2fhow-to-get-filename-only-without-path-in-windows-command-line%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
2
For future reference, Microsoft has an online Windows XP - Command-line reference A-Z which is still mostly applicable to later versions. The documentation in the answer you accepted is at the end of the section on the
for
command.– martineau
Oct 18 '12 at 3:31
@martineau: Unfortunately, the online 'Windows XP - Command-line reference A-Z' page is no longer on-line (removed by microsoft) and an alternative for this documentation is not yet available (as far as I can find any codumentation on '%~' argument documentation)
– PapaAtHome
Jul 2 '18 at 9:08
@PapaAtHome: Fortunately one can still view the command line reference via web.archive.org's wayback machine.
– martineau
Jul 2 '18 at 12:36