• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

Find root name of file in DOS

How to get the root name of a file, using dos scripting?
0
rsolomon
Asked:
rsolomon
  • 3
1 Solution
 
knightEknightCommented:
If by root name you mean the part before the .extension:

@echo off
 for %%F in (*.txt) do @echo  %%~nF
0
 
knightEknightCommented:
I used  *.txt  as a generic filespec, but it can by any filespec or a specific file.
0
 
knightEknightCommented:
Note that in a batch file, you must double-up the % symbols as I did above.  If you want to run that straight from a command line (no batch) then use single percents:

for %F in (*.txt) do @echo  %~nF
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now