Replace Mac line breaks with Windows linebreaks?

Is there a simple AppleScript that could process a plain text file created on a Mac and replace the line breaks with Windows-compatible \r\n line breaks?
I thought this would be a very simple task but have been searching for quite a while and can't find anything.
Thanks.
Paul

There are several approaches to this. Here's one of them:
set theFile to (choose file)
set MacText to paragraphs of (read theFile)
set {oldDelims, my text item delimiters} to {my text item delimiters, (return & linefeed)}
set WindowsText to MacText as text
set my text item delimiters to oldDelims
set outputFile to (open for access theFile with write permission)
set eof outputFile to 0
write WindowsText to outputFile
close access outputFile
To explain, the first line asks you to choose the file in question - you could use any technique to identify the file, including hard-coding the path or using a drag-and-drop handler.
The second line gets the current paragraphs and calls them 'MacText'
The third line saves the current text item delimiters in oldDelims and sets the new text item delimiters to the CR+LF combination.
The fourth line performs the magic of transforming the file. It does this by coercing the list of paragraphs (obtained in line 2) into a single text block, and it inserts the current text item delimiters between each text item, miraculously giving you CRLF-terminated paragraphs.
The fifth line restores the text item delimiters to whatever they were before (you don't know what they were, but don't need to know what they were, as long as you restore the previous setting - it's unlikely you want CRLF moving forwards).
The rest of the script (lines 6 through 9) reopen the file you originally selected, sets the EOF to 0 (effectively wiping the file contents), then writes the CRLF-terminated text to the file and finally closes the file.
Note that some people might suggest using text item delimiters to break up the original text file on CRs but that would be wrong IMHO. The reason is that 'paragraphs of' can detect and handle both CR and CRLF-terminated paragraphs, leaving you with clean paragraphs into which you insert CRLFs.
This means that if the file originally had CRLF-terminated paragraphs you'd end up with the same data, but at least there was no harm done.
In contrast, if you simply searched for CRs and replaced them with CRLFs you could have the situation where you selected a CRLF-terminated file (maybe you didn't realize it was already in the Windows format) and your script would blindly replace each CR with CRLF, meaning you'd end up with CRLFLF combinations, which is very wrong.

Similar Messages

  • I have a mac book pro with Windows for Mac, I have really been struggling to figure out a keyboard shortcut to switch between 2 excel files can someone suggest a solution please ?

    I have a mac book pro with Windows for Mac, I have really been struggling to figure out a keyboard shortcut to switch between 2 excel files can someone suggest a solution please ?

    someonehelpmaddy wrote:
    My Mac knows that it is connected to the montior...
    Open your Displays system preferences.  Is there an Arrangement tab and does it show two screens?  If no Arrangement tab then your mac does not know it has two screens.  Maybe smc and pram reset will shake it free and maybe not.  Maybe there's something wrong with the connection.  Thunderbolt plugs are similar to mini-displayport plugs so make sure the plug is pushed firmly in so that essentially all the metal part disappears inside the socket.  The plugs can be a little tricky in that you need to make sure the plug is fully seated in their socket.
    If you do see two screens in the Arrangement tab then click Detect Displays and Gather Windows to get the Displays preferences of the other monitor on to your main monitor.  Check the resolution and if there is a refresh rate check that as well.

  • Mac Mini stuck with windows install, won't boot from OSX DVD

    Ok, I just bought this mac mini from ebay, yeah i know but it was cheap. I got it and it came with windows xp installed. I thought ok, I will just pop in my snow leopard disk and get rid of windows. so i put in retail new copy of snow leopard in the drive, shutdown, power on, hold C... grey screen for a little while then into windows boot screen. Thought ok, I will try reset pram, option + command + p + r, nothing... just boots into windows. I have tried to original osx 10.4 restore disks that came with the machine with the same results. I also tried holdind D during boot with the original disks and it still does the same thing.
    I have also tried holding down option during boot, thinking it would give me my boot options, nothing still goes into windows. I am using a new aluminum white keyed usb apple keyboard and apple optical mouse, all plugged into the back of the machine.
    I don't know what to do next, if I can't find the solution it looks like i am going to have to take this thing apart and yank the drive and format it on my other machine with osx partition.
    thanks

    There's a couple more options yet.
    First, try a different USB keyboard.
    Second, when in Windows use the Bootcamp system tray utility to choose bootup from the OSX partition. You can install the Bootcamp system tray utility from the SL disk.
    Third, if you have another Mac and an appropriate firewire cable, bring the Mini up in Target Disk Mode and blat the disk that way.

  • Mac Mini Server with Windows installed?

    I have a windows application for a business otherwise all mac OS.  Want to run the windows app on a mac mini server allowing access from multiple workstations.  Desire to not committ entire mac mini server to windows so will need to partition I assume.  Any thoughts?

    You could try virtualizing the windows machine
    Virtual box is free I can't remember if it's free for commercial
    use
    Or VMware or parallels
    You could also try wine it's open source
    And allows running of (some) windows programs on Mac
    I've had mixed results with wine I haven't used it for ages
    Personally I think virtualizing would be the way to go
    Virtualizing would allow you to have snapshots and
    Backups would be somewhat easier
    If your unfamiliar with virtualizing
    It basically runs a compete OS as software on the host machine
    You can virtualize osx server on osx server if you desired
    Or most other OS, Linux, BSD, windows, windows server
    You just need enough grunt hard drive space and ram to host the virtualized OS

  • How do i get my touch pad to work on my Mac Book Air with windows/office

    How do i get my touch pad to work on my Mac Book Air using boot camp with windows and office.  Does it work the sale as on the Mac side?

    Did you install the Windows Support Software ?

  • Replace Zorin 9 OS with Windows 8.1 OS

    I have an opportunity to purchase a HP TOUCHSMART 15-D069WM, 15.6" Intel [email protected] GHz, 6 GB, 500 GB for a reasonable price.  However it has Zorin 9 OS.  How can I replace the OS with Windows 8.1  I have the retail Windows 8.1 discs.

    Hi,
    Please start from step #2 of the following article:
        http://windows.microsoft.com/en-AU/windows-8/clean-install
    more reading:
       http://www.howtogeek.com/187525/how-to-perform-a-clean-install-of-windows-8.1-with-a-windows-8-key/
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Files to memory stick from mac not compatible with windows?

    Before I installed leopard I was easily able to copy photos, files and other docs to my memory card sticks and have them read on windows no problem but not now with leopard.
    What should I do? What's the best format to format the card so that windows users can read my files or that I can transfer my files to a HD from my mac and copy to windows.
    thanks

    Well...it seems like my perfectly good 2GB card crashed on me. Your right, it doesn't work on any computer and it even failed the format option in windows.

  • Insert Line Break with Syndicator

    Hello,
    I have a quite "simple" question: Is it possible to insert a linebreak after a record set using the MDM Syndicator? By default there are some values offered, like ',' or ';' and so on to seperate values, and you can specify seperators by your own. But how to specify a line break?
    Thanks for your replies!
    Andreas

    Andreas,
    As far as I know, there is no support for specifying the line break. The records automatically appear in separate rows (If you are using Flat file as Destination).
    If you still need to specify your own custom character at the end of each line, create a "Custom Item" and enter the required character in the "Formula" for Custom Item and map this custom Item to a newly created destination field (at the end of all destination items).
    Hope this helps,
    Regards,
    Rajani Kumar

  • Mac print sharing with windows issue...

    I set up a intel iMac to share its printer with a dell laptop. From what i can see in the printer's queue..all the jobs get sent from the laptop to the iMac; however, it doesn't print anything. It seems that windows is sending the print job and the iMac is receiving it but nothing is printing.
    what could be the solution?

    I have a very similar problem....
    I got a MAC PRO a couple of weeks ago and I have two USB printers (an EPSON CX 4200 and a CANON S900 connected to it).
    I tried both Ifelix procedures to add the printers connected to the MAC and I had problems with both procedures.
    If I try the http://mac-ip:631/printers/printer-name I am successful in adding the printer to the Laptop running windows XP however when I try to send something to that printer the job goes straight to the "completed" queue on the MAC.
    I spent two hours with Apple support on the phone today and they could not figure out what was going on and suggested that I post my issue to this forum to see if anybody has any ideas.
    I also tried to configure the printers using Bonjour (as per Ifelix method) but at some point during the printer setup I get an error message indicating that I do not have "sufficient access" to install the printer driver even though I am logged in as admin on the windows XP computer.
    Has abybody experienced similar pain? Is anybody here being able to print to printers connected to a MAC PRO from a Windows XP laptop?
    I should also say that my computers are in a network and both are connected to a Linksys Wireless Access point/router.
    The Laptop is a wireless laptop and the mac pro is conneced to the linksys router via a regular network cable.
    Also, I have no issues printing straight from the mac to both printers.
    Would appreciate any suggestions/comments.
    Thanks in advance for your time.
    regards,
    marcelo

  • Missing line breaks with Excel

    Hello,
      Am downloading certain into Excel using BSP. I am changing response mime type to "application/vnd.ms-excel" and am sending tab-demilited string as data.
      Some of the columns should contain line break within the cell( Mean the Alt-Enter in Excel cell ). I tried using the character code 10 and also 13 for the break. But it did not work.
      How do I cause a line-break in the Excel cell? Any work-arounds??
    Thanks.
    Srinivas.

    Hi Srinivas,
    I think you don't have the possibility to add line breaks into a tab seperated file. You rearly had to create an excel file. Unfortenately AFAIK this is not possible in ABAP. I've done this in PHP using the <a href="http://pear.php.net/package/Spreadsheet_Excel_Writer">Spreadsheet_Excel_Writer</a>.
    Regards
    Gregor

  • Deleting extra forced line breaks with Find/Change

    Ladies and Gentlemen,
    I'm importing word .doc that are text-heavy and the formatting is such that there are lots of extra forced line breaks creating a blank line between paragraphs.
    To avoid manually deleting the extra forced line breaks to eliminate the blank line of space between paragraphs, what are the best steps to doing this an easier way?
    Any advice on clear steps to do it using the find/change option?
    Thanks in advance as always..
    JRH

    Are you talking about two hard returns [Enter] in a row, or a soft and hard return [Shift + Enter] and [Enter]? A forced line break is a soft return, but most Word users would just hit the return key for an empty paragraph to get an empty line.
    In either case, you can do a simple text find change, if GREP intimidates you. Use the special characters menu to enter either two "end of paragraph" or a "forced line break" and "end of paragraph" markers into the find field and a single "end of paragraph" marker into the change field.
    This is included as part of the "Find/change by list" sample script which adds some other common cleanup functions like converting two spaces to one. The advantage to using GREP is it will find any number of consecutive paragraph end markers and convert to one in a single pass, while a text search must be run multiple times to catch the heavy handed author.
    Peter

  • Using a Mac formatted ipod with windows itunes

    Any ideas how I can update my mac formatted ipod on windows based itunes without losing all of my music? Every time I connect onto my pc I just kept being told I need to restore factory settings, yet when I connect to my mac it's fine.
    Any help is greatly appreciated

    If your iPod is formatted for Mac it won't run natively on a PC because the Windows OS does not support the HFS Plus file system and therefore will not see the drive: How to determine your iPod's disk format
    Macs can read Windows drives so you could restore and format the iPod on a PC then connect it back to the Mac and reload your songs. iTunes will allow you to use an iPod formatted for Windows on a Mac but Apple currently only fully supports using the iPod shuffle in FAT32 format on Mac, in other words all future software updates for the iPod would have to be carried out in Windows to maintain the formatting. Alternatively there are third party programs that will allow you to use a Mac formatted iPod on Windows, this is one for instance gets good reviews. It's a commercial program so you'll have to purchase a license to use it:: XPlay 2

  • Line break with voice control (dictation)

    Hi there,
    How can I get a line break (or section break) while using voice control (dictation)???
    Thanks a lot!!
    Cheers!
    Boscha
    current device: BB Q10 (OS 10.3.1.1565)
    former device: Bold 9780 (OS 6 - FW 6.0.0.534)
    Carrier: O2-Germany

    When I click the mic icon on my Q10-screen the dictation stops... no line break!
    Please help!!
    current device: BB Q10 (OS 10.3.1.1565)
    former device: Bold 9780 (OS 6 - FW 6.0.0.534)
    Carrier: O2-Germany

  • Mac Pro compatibility with Windows 7 and Bootcamp

    This apple post : http://support.apple.com/kb/HT3920
    says they will not support Win7 on older Mac Pro's (e.g. 2.66ghz dual). Does anyone know why?
    When I try to instal Win7 on Bootcamp 3 I get a BSOD and it will not run.
    Suggestions?

    If you look closely you see that EFI64 (UEFI 2.x) is the demarcation line of 2008 between support or not is EFI firmware.
    2006-7 and you get the EFI menu prompt with 64-bit Vista and 7. Mac Pro and others pre-2008. Apple's idea of supported or not may not be ours. If you want to troubleshoot yourself.
    BC 3.0 - built during the summer, before Windows Oct 22nd, buggy, and rushed. Often due to the HFS read feature, just rename "AppleHFS.sys" to something else is often enough. Not sure why your system is having trouble without knowing more.

  • Bootcamp performance: Mac Air 11 with windows 7

    I was looking to replace my wife's Lenovo U110. She needs ~11", light netbook. Her main usage is remote desktop to her office windows machine, running few company specific apps to access company resources, running MS Office applications (Word and Powerpoint)
    I recently bought her Sony X, which was nice on paper (11/6", 1.5 lb, etc) but she could not stand keyboard. (I am using it now as a travel laptop and think that Intel Atom is the worst even CPU).
    Anyway, when I saw new mac air 11, I thought that it fits perfectly her needs. I offered my wife to buy it but apparently that special (from company) soft does not work well with MAC OS. So, what I am thinking now is to get MacAir 11" with 128Gb SSD and to install Win 7 with bootcamp. Then she would be using it most (all) the time running win 7.
    My question is, can I assume that MacBook Air 11 with bootcamp and win 7 64 bit will provide "experience" equivalent of running Win 7 on "Microsoft-native" laptop. I mean both from point of view of CPU performance (1.6 GHz should be more than enough normally, so small performance hit would not be a problem) and also the easiness of usage (software instillation, access to hardware resources, etc). I understand that bootcamp is not an emulation but I have never used it before myself...
    Thanks.

    Windows will run fine on the Macbook Air. In fact, if she doesn't like the Mac OS at all, she can wipe the drive clean and install Windows. Bootcamp is just a fancy name for partitioning the drive and easing driver functionality. There's no difference booting up Windows on a Macbook vs booting up Windows on a Dell or Sony-- it runs natively.
    You will need the Mac OS usb that comes with the Air to install the Bootcamp drivers on Windows (graphics, sound, trackpad, etc...). To save both of you the headache, once you've installed the Bootcamp drivers (and updated them)- go into your notification area and open the BootCamp control panel. Select 'tap to click' on the trackpad tab, then close the control panel.
    The trackpad will work just like any other PC (even better). Two-fingers to right-click, 1 finger to left-click.

Maybe you are looking for

  • IR Search bar display on the right when no data found

    How do I get the Interactive Search bar to be left justified when no data is found. I'm using Sand 10 Theme, and the region my interactive report is in is Page Template Region Position 3 Does anyone have a suggestion on this? Edited by: deandyno on A

  • Parallel text box in selection screen

    Hi all, Can anyone please tell me that how can i create parallel text boxes in selection screen? Exa : Company code    <Input box>                        Date       <Input box>          Pers No.              <Input box>                    Cust No. <I

  • JNI_CreateJavaVM method crashed

    I m trying to Invoke Java from Cpp code for a certain application. I m using JDK 1.5 Please Help me in sorting out the problem. Thank u in advance I m posting the sample code which i tried #include "jni.h" #include <dlfcn.h> #include <link.h> #includ

  • DVI to RCA cable

    Anyone know where I can get hold of a cable for my MacBook Pro (circa 2005) with a DVI port so I can see the output on my TV?

  • Should my Mac Air stay plugged in to electric or should it be disconnected from time to time?

    Can the battery be overcharged if its left plugged in to an electric outlet. Also, will keeping it plugged in overhet the computer? Some devices have a special circuitry that prevents overcharging. Is this true for the MAC Air? Thanks.