

InterviewSolution
Saved Bookmarks
1. |
Solve : Inserting Blank Lines in a set of text files? |
Answer» <html><body><p>Hi,<br/><br/>This being my first ever post, i would want to ask for some help with Dos/Batch file.<br/><br/>I have a set of 20 files in a Folder in my C Drive.<br/>these files are plain text files, i want to add a Blank line at the end of these files.<br/><br/>I want to create a Bath file that can open these files and insert the Blank line at the end n save the file.<br/><br/>Is it possible? please help me out.. im a total newbie in this field..<br/><br/>Thanks alot for your help.can someone please help me out.. i really need to get this working <br/><br/><a href="https://interviewquestions.tuteehub.com/tag/daily-245095" style="font-weight:bold;" target="_blank" title="Click to know more about DAILY">DAILY</a> i have to edit 20 files or more.. If all you need is a blank line on the end of all files in a folder then type this in at the command line<br/><br/> Code: <a>[Select]</a>For %A in ("*.*") do Echo. &<a href="https://interviewquestions.tuteehub.com/tag/gt-249387" style="font-weight:bold;" target="_blank" title="Click to know more about GT">GT</a>;> %A<br/>explanation available on request! Quote from: gpl on August 03, 2010, 05:01:01 AM</p><blockquote>If all you need is a blank line on the end of all files in a folder then type this in at the command line<br/><br/> Code: <a>[Select]</a>For %A in ("*.*") do Echo. >> %A<br/>explanation available on request!<br/></blockquote> <br/>Hi, thanks alot for ur reply.. yes for sure i would want an explanation as im not much into scri[pting so i really dont knw how to go about doin this.<br/>please assist me.I get the impression that you are not sure even how to get to the command prompt ?<br/><br/>In the start menu, click on Run and then enter cmd and press return. If you find yourself using the command prompt a lot, then there is a useful microsoft tool that adds a new option to the right-click contect menu in windows explorer called 'Command Prompt Here' which opens up a command window in the selected folder <a href="https://gallery.technet.microsoft.com/ScriptCenter/en-us/d50e36fd-0454-4df1-aa35-3416f44789cc">http://gallery.technet.microsoft.com/ScriptCenter/en-us/d50e36fd-0454-4df1-aa35-3416f44789cc</a> however as even microsoft do not guarantee this for <a href="https://interviewquestions.tuteehub.com/tag/vista-728089" style="font-weight:bold;" target="_blank" title="Click to know more about VISTA">VISTA</a> or win 7, I would hold off for now.<br/><br/>When the command window opens, you need to go to the folder that you wish to process the files in:<br/><br/> Code: <a>[Select]</a>cd /d "x:\<a href="https://interviewquestions.tuteehub.com/tag/path-11833" style="font-weight:bold;" target="_blank" title="Click to know more about PATH">PATH</a>\to my files"the x: refers to the disk drive the files are on (if a network drive, it needs to be mapped to a drive letter) and \path\to my files refers to the folder on the drive that contains the files. the quotes around the drive and folder name are important if the path might contain spaces, it doesnt hurt to include them. CD is the command to change directory (folder) the /d parameter tells it to change the drive too.<br/><br/>Now for the command I told you to type in ....<br/>the first <a href="https://interviewquestions.tuteehub.com/tag/part-238139" style="font-weight:bold;" target="_blank" title="Click to know more about PART">PART</a><br/> Code: <a>[Select]</a>For %A in ("*.*") dosets up a loop to look at all of the files in the current folder (thats the *.* part). The %A is a variable that for each iteration will hold the filename.<br/>The last part is what we do with each file<br/> Code: <a>[Select]</a>Echo. >> %AEcho is used to send a message to the screen, however you can send the message to a file (or the printer or comm port) by using the > and >> 'redirection' symbols. <br/>> will replace the file, while >> tacks the message on to the end.<br/>Echo on its own give the (not very) useful message 'Echo is on' - or off. Adding the dot to the end makes it send a blank line<br/>And thats all there is to it. I recommend that you try stuff out, read the various help guides on this site and others and come back when you are stuck.<br/><br/>Good luck<br/>Graham<br/>Thanks alot gpl<br/><br/>It has solved my problem!To follow up my previous post, I have stumbled across this with regasrd to opening a command window in Vista and I assume Win 7 also<br/>"Open Command Window Here" in Vista<br/>It is now easy to open a command prompt referenced to a folder of your choice in Vista. If the Shift key is held down while right-clicking a folder, the context menu will contain an entry, "Open Command Window Here". Selecting this entry will open a command prompt with the chosen folder as the reference point for commands.<br/><br/>You live and learn!!</body></html> | |