mtwo Posted December 8, 2007 Share Posted December 8, 2007 i got a textfile that is like this: a girl@a boy@a dog@.... and so on I want to in some way split this file at those "@" so they become small files that are named like this 01.txt 02.tx .. i tried csplit but i couldnt get it to work any type of help would be appreciated Link to comment Share on other sites More sharing options...
A Nonny Moose Posted December 8, 2007 Share Posted December 8, 2007 I'd try Automator, but that would force some highlighting and clicking. Link to comment Share on other sites More sharing options...
thePixeler Posted December 9, 2007 Share Posted December 9, 2007 See if this script works. You can drop text files on it or double click the app and choose one. Right now it only works with ".txt" files. Text_Spliter.zip Link to comment Share on other sites More sharing options...
mtwo Posted December 9, 2007 Author Share Posted December 9, 2007 Thank you very much Pixeler but I got a strange problem :S It says the variable theFolder is not defined .. But when i look into the surce it seems that it is defined .. But I´m not so good in apple script so i could be that it´s defined in the wrong way. tell application "Finder" set theNumber to "" repeat 5 times try make new folder at ((path to desktop) as string) with properties {name:"Text fragments " & theNumber} set theFolder to (((path to desktop) as string) & "Text fragments " & theNumber & ":") as string exit repeat on error theError if theError is "The operation could not be completed because there is already an item with that name." then set theNumber to theNumber + 1 end if end try end repeat end tell Link to comment Share on other sites More sharing options...
thePixeler Posted December 10, 2007 Share Posted December 10, 2007 OK try this one! You'll have to edit it first though, open it up and change the first line to the path to your desktop. So change... property pathToDesktop : "Macintosh HD:Users:yourusername:Desktop:" To... property pathToDesktop : "Macintosh HD:Users:Steve Jobs:Desktop:" Text_Spliter.zip Link to comment Share on other sites More sharing options...
pafmax Posted December 11, 2007 Share Posted December 11, 2007 thePixeler.... I just have to say I was looking for this exact type of script today to process one of my work txt files (about 80M of txt with 2000 merged files inside) The one tiny litle ploblem is that, when it finds the character or piece of text you´d like to cut, it cleans that character. In my adapted program, if I ask the program to cut everything after "position" the resulting txt file will start with "osition". Can this be solved? It´s just a nitpick, I know.... Thanks for the script, I´ll be sure to mention you! (you´ve just saved me a lot of work!) Edit: Ok, nevermind, I can actually use this "bug" in my favour! Link to comment Share on other sites More sharing options...
thePixeler Posted December 12, 2007 Share Posted December 12, 2007 thePixeler.... I just have to say I was looking for this exact type of script today to process one of my work txt files (about 80M of txt with 2000 merged files inside) The one tiny litle ploblem is that, when it finds the character or piece of text you´d like to cut, it cleans that character. In my adapted program, if I ask the program to cut everything after "position" the resulting txt file will start with "osition". Can this be solved? It´s just a nitpick, I know.... Thanks for the script, I´ll be sure to mention you! (you´ve just saved me a lot of work!) Edit: Ok, nevermind, I can actually use this "bug" in my favour! It's not really a bug, it would take one simple line of code to make it include the cut character. I thought this would be annoying so i didn't make it do this. But you say the current version works for you so I'll keep it the way it is, for now. Link to comment Share on other sites More sharing options...
iMichael Posted March 3, 2010 Share Posted March 3, 2010 I've tried to make this work with Unicode files, with no luck ("open" and "write" as «class utf8»). Keeps saying "Can't make alias -path to file- into type file specification" Anyone knows how to fix this? Link to comment Share on other sites More sharing options...
thePixeler Posted March 4, 2010 Share Posted March 4, 2010 I've tried to make this work with Unicode files, with no luck ("open" and "write" as �class utf8�). Keeps saying "Can't make alias -path to file- into type file specification"Anyone knows how to fix this? Blast from the past! I don't think I can help you, man. Just yesterday I sold my Mac. All I have now is a Windows box. From my previous posts it appears that the script will only works on ".txt" files. If you're using unicode that probable means that you have ".rtf" files. I really doubt that this will work but try changing all references of ".txt" to ".rtf" in the script. I vaguely remember doing something with unicode before and you had to do something with theses funky arrows or something... You might also want to try modifying the script to use TextEdit as a means of opening and saving your files. Link to comment Share on other sites More sharing options...
Recommended Posts