Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a text file that contains gmail contacts, after each address there's the name of the email address owner example : John(at)gmail(dot)com:John and some other emails like this : John(at)gmail(dot)com;John
each address is in a new line, I want to delete all names and keep just the addresses, so I don't have to do it manually each time. how can I do this in batch script. I want to delete everything after ":" or ";" in every line. Thanks
It's a simple one-liner:
(FOR /f "delims=:;" %%a IN (filename1) DO ECHO %%a)>filename2
where filename* are your filenames and > should be replaced by >> to append to filename2 rather than creating filename2 anew.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Is something like
Input: 1 > say.bat
Output: 1
Possible?
Probably Not just wondering.
Also how would I get what was passed before the > sign?
If you know if it is possible or impossible, please try to comment so I don't have to wait forever.
If you are trying to say some text into a Batch file or any kind of file. Try these steps:
Use "echo" at the start of the script and then add your text you would like to output.
Add ">>" onto the "echo" Line and enter the file name, along with the extension of the file you would like to write to. (This will create a file if it does not exist)
For Example:
echo Hello World! >> file.txt
You will be able to use this as many times as you want.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I want to create 100 txt files starting from txt1 to txt100 with string data (i.e not to create an empty file) and it's doesn't matter if the data duplicate or not, I've just wanted to add some data in each file created in a specific path, so how can I do that?
We need a little bit more info such as what is going in the files and what name do you need for the files.
Give this a go as a start. It should create 100 files in C:\temp named as MyFile_1.txt through to MyFile_100.txt and each would contain the text Your Contents Here
#echo off
setlocal
set "txtpath=C:\temp\"
for /L %%a in (1,1,100) do >>%txtpath%MyFile_%%a.txt echo Your Contents Here
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a batch of PDF files in a folder and I am trying to rename them.
Example:
File1_20170501_data.pdf
File2_20170401_statistics.pdf
Sale2_20170404_Misc.pdf
I only want to keep the first six characters of each file name (the five characters left to underscore and the underscore) and replace everything behind with sample data.
The final file names should be:
File1_sample data.pdf
File2_sample data.pdf
Sale2_sample data.pdf
Anyone can advice which command line to use for this file renaming task?
Given your provided information at the time of this answer, one simple command should do what you need:
Ren "C:\path to\a folder\?????_*.pdf" "?????_sample data.pdf"
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I still don't understand what makes you more confused here. Anyway I got solution for my first question. I am able to merge 2 files and able to insert the content in first file.
Now come up with a scenario where I'm trying to remove a specific string from file1 and copy file1 to file2.
Below my code
set file1=Y:\NAS\EODReport\\"CAT Channels Audit Report_%TODAY%**.TXT\"
FINDSTR /V "Transaction Gateway Item Listing Creation Amount Seq Y:" %file1%> file2.txt
In file2, i can see the file1 namee (Y:\NAS\EODReport\\"CAT Channels Audit Report_%TODAY%**.TXT\) is getting copied all over the line.
How can i remove that filename in my file2 content ?
without knowing what particular position means, i have to leave this part for yourself. basically it's as easy as:
sed -n '1,/your particular position/p' s1 >> s3
cat s2 >> s3
i assume by merge you mean to append. it's better if you phrase your question better first.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
Usually, I open cmd and use
ren oldname.jpg newname.jpg
and that works fine, but now I have an issue where I have to rename the same file into 50 or 100 different names.
How can I rename these, but keep the original file (so that I can continue saving it as a different name).
Thanks!
It seems like you need several copies from the same file. This should do it.
copy oldname.jpg newname.jpg