Reputation: 171
I am new to batch scripting and i was trying a new thing. I have a sample text file sample.txt.
It contains path of folders and files. Here is the file sample.txt:
C:\Users\admin\Desktop\Sample\ABC\Apple 1
C:\Users\admin\Desktop\Sample\ABC\Apple 1\file1.txt
C:\Users\admin\Desktop\Sample\ABC\Apple 2\file2.txt
C:\Users\admin\Desktop\Sample\ABC\Apple 3
C:\Users\admin\Desktop\Sample\ABC\Apple 4\hello.docz
C:\Users\admin\Desktop\Sample\ABC\Apple 4
I want to delete the path lines from sample.txt which are just folders & other files but want to keep text files. I want the output to be stored in the same file sample.txt:
C:\Users\admin\Desktop\Sample\ABC\Apple 1\file1.txt
C:\Users\admin\Desktop\Sample\ABC\Apple 2\file2.txt
Upvotes: 0
Views: 70
Reputation: 57262
findstr /e /i "\.txt" "sample.txt" > "new.file"
move /y "new.file" "sample.txt"
Upvotes: 3