In a text file many lines contain a path + filename each
How can I (from a DOS Batch script) remove all the paths (including the last \") from all lines which contain a path+filename?
Just the filename should remain.
If a line is empty or contain just other text then nothing should happen.
How to remove a path from all lines in file? Filenames should be kept.
Moderator: DosItHelp
Re: How to remove a path from all lines in file? Filenames should be kept.
I just went back and looked at a lot of your threads. I see no reason why you shouldn't know how to do this already with all of the code you have been given the past 10 years.
Many of your threads show the usage of the `FOR` command modifiers that allows you to split apart the path and file name and file extension. There has been code in your questions that use all three of those modifiers.
Many of your threads show the usage of the `FOR` command modifiers that allows you to split apart the path and file name and file extension. There has been code in your questions that use all three of those modifiers.
Code: Select all
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