I have various amounts of text files that need to have the first 26 lines deleted. I have tried the below bat but it doesn't want to even finish the first text file. The files are named data (1).txt, data (2).txt, data (3).txt, ... etc.
At first I tried...
more +26 "data (1).txt" > "data (1).txt.new"
move /y "data (1).txt.new" "data (1).txt"
This worked but it would be extremely time consuming to change each number seeing as I have ~100 text files.
So then tried to do the below.
for %%f in (*.txt) do (
more +26 "%%f" > "%%f.new"
move /y "%%f.new" "%%f")
To me it seems like this should work but it's not, it just pulls up the command line and stalls on the first file, it does create the "NEW" file but looks like it only copied half of the original text file. The files are anywhere from 1MB to ~300MB each.
So my question is simple.. What am I doing wrong and can anyone provide help/tips?
UPDATE
So I've been continuing to play with the second option and it seems to work for files up to ~125MB anything over that and it just pauses and doesn't complete the operation. Not sure if there is a fix for that or possibly a better option then using a batch file. Again any help is appreciated.
UPDATE
I was able to get what I was looking for through JAVA.
sadd
import java.io.bufferedreader;
import java.io.file;
import java.io.filereader;
import java.io.filewriter;
public class cleanfiles {
public static void main(string[] args) throws exception {
string currdir = system.getproperty("user.dir");
file inputdir = new file(currdir + file.separator + "input" + file.separator);
file[] inputfiles = inputdir.listfiles();
String outputdir = currdir + file.separator + "output" + file.separator;
for (file inputfile : inputfiles) {
if (inputfile.getabsolutepath().endswith(".txt") == false) {continue; }
file outputfile = new file(outputdir + inputfile.getname() + ".csv");
bufferedreader reader = null;
try {
reader = new bufferedreader(new filereader(inputfile));
writer = new filewriter(outputfile);
string line;
while ((line = reader.readline()) !=null) {
if (line.startswith("Point")) {
writer.append(line);
writer.append("\r\n");
break;
}
}
while ((line = reader.readline()) !=null) {
writer.append(line);
writer.append("\r\n");
}
} catch (exception e) {
} finally {
try {
reader.close();
writer.flush();
writer.close();
} catch (exception e) {}
}
}
}
}