Hey,
I have a series of files (*.mail, but they are essentially *.txt) in a single folder.
I would like a batch script to delete the first character (which should always be a "-") within each text file (so not editing the filename, but the file's content).
(Optionally it can delete all "-" characters in the text files, but I would prefer to just delete the first one).
I'd like this edited straight in the existing file, no output files, etc.
For now I have been using Notepad++'s "Find in Files"-function, which works well, but I would prefer a batch-based solution.
Can someone help me out?
Thanks!
Batch remove first character of all text files in a folder
Moderator: DosItHelp
-
- Posts: 1
- Joined: 11 May 2015 05:18
Re: Batch remove first character of all text files in a fold
Just try this:
This uses a native Windows batch script called findrepl.bat (by aacini)
It can also be found here: viewtopic.php?f=3&t=4697
Place it in the same folder as the batch file, or in a folder that is on the system path.
Code: Select all
@echo off
for %%a in (*.txt) do @(
findrepl "^-" "" < %%a > %%~na.tmp
del %%a
ren %%~na.tmp %%a
)
This uses a native Windows batch script called findrepl.bat (by aacini)
It can also be found here: viewtopic.php?f=3&t=4697
Place it in the same folder as the batch file, or in a folder that is on the system path.
Last edited by Ben Mar on 12 May 2015 00:15, edited 2 times in total.
Re: Batch remove first character of all text files in a fold
You can use JREPL.BAT. The following works from the command line - no batch required:
If used in a batch script, then
Dave Benham
Code: Select all
for %F in (*.txt) do @jrepl "^-" "" /jendln "skip=true" /f "%F" /o -
If used in a batch script, then
Code: Select all
@echo off
for %%F in (*.txt) do call jrepl "^-" "" /jendln "skip=true" /f "%%F" /o -
Dave Benham