Hi Eileen,

I think you may have missed my earlier post giving directions on how to import 
in answer to your question.  I'll paste it into a second post. But first, to 
answer your current question, I saved the recipes that I want to import into 
Paprika as .TXT files, and generally just keep these as plain text.  If you 
have a DOCX file and open it in TextEdit, the Command-Shift-T shortcut will 
change the format from rich text to plain text.  Then you can just save the 
file with .TXT extension.  However, doing this file by file can be tedious, and 
a year and a half ago, Sarah on the mac-access list asked me whether there was 
a simple way to batch convert a bunch of recipe files she had grabbed that were 
either in .RTF or .DOC formats to .TXT.  The Mac has a "textutil" command that 
you can use under Terminal to convert document formats. Since most people 
aren't comfortable working outside of the GUI environment, I put that command 
into a short AppleScript that would let you select a directory in Finder and 
run the textutil conversion on any files of type .doc, .docx, or .rtf that are 
in the selected folder and change them to .txt versions.

The file name extension of ".YML" is only used by the Paprika Recipe Manager 
importer to identify how it should interpret the format of the contents.  This 
is exactly a text format file.  So I keep the individual recipes in TXT files, 
but I combine them into a group of many files that I import at one time, and 
rename as "recipes.yml".  You can also experiment by first importing a test 
recipe to check that you like your selection of importing options, and then 
import batches of recipe files named "recipes1.yml", "recipes2.yml", etc.  (I 
explained this in more detail in my post yesterday)

I'll give instructions on how to save my AppleScript on your system and run it 
to batch convert your recipes to text.  I'd usually try mailing an attached 
AppleScript file to you off list, which would then automatically open up in 
AppleScript Editor, but I'm not sure whether the GateKeeper security in the 
current systems would now let you open and run it directly, so I'll describe 
how you can create the AppleScript yourself.

AppleScripts are short programs that users can write to perform specific 
actions, like the script that VoiceOver uses to tell time, or one that reports 
the battery level. You can save AppleScripts into specific locations such as 
the Library/Scripts folder for your user account, or the system's 
Library/Scripts folder. The AppleScripts you create can then be accessed as 
options from the menu bar, or they can be assigned to keyboard shortcuts.  You 
can also just run them as programs from any location.  

To use this AppleScript, open the AppleScript Editor under the Utilities 
folder, then copy and paste in the text that I'll post below.  I'm going to 
assume that you have already created a folder on your Mac with copies of the 
recipes you want to convert to text, so we can directly run the AppleScript 
conversion. 

1. In Finder press Command-Shift-U to move to the Utilities folder, type "a p" 
to move to the AppleScript Editor, then press Command-Down Arrow to open the 
AppleScript Editor.
2. In AppleScript Editor, if focus is on a "New Document" button, press it 
(VO-Space) to open the Editor  (This step is not necessary in older versions of 
the Mac OS X operating system where launching the editor directly opens it.)
3. Copy the lines of text below that appear between the "---begin script---" 
and "---end script---" statements below, excluding those lines
---begin script---
(* Convert doc and rtf files to text using the textutil convert option
Written for Sarah on the mac-access list. 
Usage: Run the script and select the folder containing your file in the dialog 
window.  The program  will create text versions of these files in that folder 
with the same name and .txt extension.   
July 15, 2012  Esther
*)
set sourceFolder to choose folder
tell application "Finder" to set theFiles to files of sourceFolder whose name 
extension is in {"doc", "docx", "rtf"} or creator type is "MSWD"
repeat with oneFile in theFiles
  do shell script "textutil -convert txt " & quoted form of POSIX path of 
(oneFile as text)
end repeat
---end script---
4. Command-tab from mail to switch back to the AppleScript editor
5. Press Command-R to run the AppleScript.  This will bring up a dialogue 
window prompting you to choose a foler.  All the regular Finder shortcuts work 
here: Command-Shift-H (home directory), Command-Shift-D (desktop), 
Command-Shift-O (documents), Command-Shift-C (computer), Command-Shift-G (go to 
folder whose path you type in), etc.
6. Select the folder of your recipes in the dialogue window.  The script should 
convert all the files with .docx etc. extensions and create files with similar 
names with .txt extenstions  You can separate these, for example, by choosing 
list view and sorting by modification or creation date, or move these into a 
separate folder.  

I first check a few individual recipe files that the importing format works as 
I like, and then I test by importing a file that has a few recipes.  Then I use 
a Terminal command to concatenate multiple TXT files into a single file and 
import that. You can do this in a few batches. 

There's a convenient free Mac App Store tool called "Go2Shell":
https://itunes.apple.com/app/go2shell/id445770608?mt=12

If you put it into the Dock (focus on item in Finder and use Command-Shift-T 
for Snow Leopard, Lion, and Mountain Lion, or Control-Command-Shift-T in 
Mavericks) then launching Go2Shell will open a Terminal window that places you 
in whichever directory is currently selected in your frontmost Finder window.  
You can type or paste in a command line in Terminal like:
cat *.txt > recipes.yml
and press return.  This command will combine all your files with .txt extension 
in that folder into a single text file named "recipes.yml".  You can change the 
name of the resulting file to anything else you want with a ".yml" extension.  
If you prefer to be conservative, you can group these into a few files by 
letter, and use commands like:
cat a*.txt > recipes_a.yml
cat b*.txt > recipes_b.yml
Remember to press the return key at the end of each line that you type or paste 
into Terminal in order to execute the command.  In the first example, you 
should be able to navigate back to Finder and locate a new file named 
"recipes.yml".  The Finder directory may not refresh unless you navigate out of 
the folder and then back into it again (e.g. Command-Up arrow and then move 
back).

In the later examples, instead of using the asterisk wild card to select all 
".txt" files, you can separately choose all ".txt" files that start with the 
letter "a" or "b", etc. and save them into files named "recipes_a.yml", 
"recipes_b.yml", etc.

My main suggestion is that you at least do a few test file imports before 
trying to import all your recipes at once.  The good thing about the importing 
process is that if there is an error,  the import will simply fail.  It won't 
import some recipes and leave out others, making you wonder which ones worked 
and which ones didn't.

If Sean is importing recipes and has a linux background with familiarity of the 
command line, he can probably do some shell scripting to make formatting 
changes.

Here's the link to the archived mac-access post I wrote, which includes the 
posted AppleScript, in case I missed any steps in my explanation:
• Re: Is there a way to batch convert rtf files to txt using osx
https://www.mail-archive.com/mac-access%40mac-access.net/msg11043.html

I'll repost my example for recipe importing in a separate second post.

HTH. Cheers,

Esther

On 5 Jan 2014, at 13:07, Eileen Misrahi wrote:

> Hi There, 
> 
> Okay. I am somewhat under the weather with a mild cold, so my brain may not 
> be processing it all today. If I have a recipe in a DOCX file format and open 
> it on my Mac with iText Express and attempt to save it, there is no .TXT 
> extension to save it as a plain text file. So, how can I resolve this and 
> begin importing the recipes into Paprika? The only think I can think of for 
> now is to go back on my PC, open each file and save it there as a .TXT file. 
> That's not what I would like to take the time doing and it doesn't expedite 
> the ability to import the recipes to Paprika. If I have to go to that extent, 
> than I might as well do the copy/paste thing. JMO. Any suggestions would be 
> terrific. 
> 
> Eileen  
> On Jan 5, 2014, at 2:00 PM, Sean Murphy  wrote:
> 
>> The import must be saved as a plain text file. YAML is just a text passing 
>> standard. By providing the fields and indentations required by the app, you 
>> will be able to successfully import recipes.
>> 
>> 
>> On 06/01/2014, at 8:14 AM, Eileen Misrahi wrote:
>> 
>>> Hello, 
>>> 
>>> I have read through this post and it brings me to ask a couple of questions:
>>> 
>>> 1. If I am using iTextExpress to set the recipe up to be accepted by 
>>> Paprika as described below, do I save the doc in the .YML file type. That 
>>> file type is not in the list in iText Express.
>>> 2. If I need to create a new file, what's the difference in just doing a 
>>> copy/paste into the set fields in Paprika?
>>> 
>>> Maybe I am just not totally comprehending the format or process to 
>>> accomplish importing my recipes that I have in a different format. 
>>> Sometimes when I am doing something for the first time, I need step-by-step 
>>> instructions to process it. I am only 4 months with the Mac, so please be 
>>> patient with me. 
>>> 
>>> Thanks in advance. 
>>> 
>>> Eileen 
>>> On Jan 5, 2014, at 1:14 AM, Sean Murphy  wrote:
>>> 
>>>> Hi,
>>>> 
>>>> Below is the extract from the user manual.
>>>> 
>>>> YAML is a simple, plain text file with sections delimited by key-value 
>>>> pairs. To indicate a block of text, use an initial pipe character, as 
>>>> shown in directions
>>>> and ingredients. Consistent indenting should be used, but the order of the 
>>>> fields does not matter, and most are optional with the exception of the 
>>>> name,
>>>> ingredients and directions. It is recommended that you use an online YAML 
>>>> validator such as 
>>>> this one
>>>> to validate your file if you're experiencing difficulties importing.
>>>> 
>>>> Note We've added several new fields: on_favorites takes a yes value and 
>>>> indicates that the recipe should be added to your favorites. categories is 
>>>> a YAML
>>>> list; the category will be created if it does not exist. photo is a 
>>>> base-64 encoded image. All these new fields are optional.
>>>> 
>>>> YAML recipe example:
>>>> 
>>>> name: My Tasty Recipe
>>>> servings: 4-6 servings
>>>> source: Food Network
>>>> source_url: http://www.google.com
>>>> prep_time: 10 min
>>>> cook_time: 30 min
>>>> on_favorites: yes
>>>> categories: [Dinner, Holiday]
>>>> nutritional_info: 500 calories
>>>> difficulty: Easy
>>>> rating: 5
>>>> notes: |
>>>> This is delicious!!!
>>>> photo: (base-64 encoded image)
>>>> ingredients: |
>>>> 1/2 lb meat
>>>> 1/2 lb vegetables
>>>> salt
>>>> pepper
>>>> 2 tbsp olive oil
>>>> 4 cups flour
>>>> directions: |
>>>> Mix things together.
>>>> Eat.
>>>> Tasty.
>>>> Yum yum yum.
>>>> 
>>>> YAML multiple recipes example:
>>>> 
>>>> - name: My Tasty Recipe
>>>> servings: 4-6 servings
>>>> source: Food Network
>>>> source_url: http://www.google.com
>>>> prep_time: 10 min
>>>> cook_time: 30 min
>>>> nutritional_info: 500 calories
>>>> on_favorites: yes
>>>> categories: [Dinner, Holiday]
>>>> difficulty: Easy
>>>> rating: 5
>>>> notes: |
>>>> This is delicious!!!
>>>> ingredients: |
>>>> 1/2 lb meat
>>>> 1/2 lb vegetables
>>>> salt
>>>> pepper
>>>> 2 tbsp olive oil
>>>> 4 cups flour
>>>> directions: |
>>>> Mix things together.
>>>> Eat.
>>>> Tasty.
>>>> Yum yum yum.
>>>> 
>>>> - name: My Tasty Recipe 2
>>>> servings: 4-6 servings
>>>> source: Food Network
>>>> source_url: http://www.google.com
>>>> prep_time: 10 min
>>>> cook_time: 30 min
>>>> nutritional_info: 500 calories
>>>> difficulty: Easy
>>>> rating: 5
>>>> photo: | (base-64 encoded image)
>>>> notes: |
>>>> This is delicious!!!
>>>> ingredients: |
>>>> 1/2 lb meat
>>>> 1/2 lb vegetables
>>>> salt
>>>> pepper
>>>> 2 tbsp olive oil
>>>> 4 cups flour
>>>> directions: |
>>>> Mix things together.
>>>> Eat.
>>>> Tasty.
>>>> Yum yum yum.
>>>> 
>>>> 
>>>> 
>>>> On 05/01/2014, at 4:22 AM, Eileens Misrahi wrote:
>>>> 
>>>>> Hello Paprika Folks,
>>>>> 
>>>>> I need some expert assistance. I copied my recipes that I have collected 
>>>>> over the years from my Win 7 PC machine onto a USB thumb drive. I placed 
>>>>> the thumb drive into an USB port on my Air, opened Paprika and attemted 
>>>>> to import the first recipe file from the drive. I received an error 
>>>>> stating that the file type was not recognized by Paprika and couldn't be 
>>>>> imported. These files are either DOC or DOCX files. What file types does 
>>>>> Paprika like and will import to the app? I didn't think this would 
>>>>> matter, but I see that I might have additional work and another folder to 
>>>>> add to this thumb drive to import my recipes. Please Advise on how to 
>>>>> resolve this.
>>>>> 
>>>>> Thanks.
>>>>> 
>>>>> Best,
>>>>> Eileen
>>>>> 
>>>>> 
>>>>> Sent from my iPhone
>>>>> 

-- 
You received this message because you are subscribed to the Google Groups 
"MacVisionaries" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to macvisionaries+unsubscr...@googlegroups.com.
To post to this group, send email to macvisionaries@googlegroups.com.
Visit this group at http://groups.google.com/group/macvisionaries.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to