Batch file to extract certain lines

Hewlett-packard / Iq505
January 6, 2009 at 16:41:15
Specs: Windows Vista , Dual Core/4GB
Hello, here I am with another batch challenge. I have a few recipe text files that all have very similar format. They are arranged something like this...(I have numbered the lines to make things clearer).

Line1: Recipe Title
Line2:
Line3: Servings
Line4:
Line5: Ingredient1
Line6: Ingredient2
Line?: Last Ingredient
Line?+1:
Line?+2: Recipe Instructions

Okay... now is where the fun begins. I need to know how to make a batch file that will copy Line 1 - Line4 and then append all of the text starting from Line?+2 to this and save it to a new file that keeps the original filename but with the suffix of "-Instr" added to the filename. The new file would look something like this...

Line1: Recipe Name
Line2:
Line3: Servings
Line4:
Line?+2: Recipe Instructions

That is the first part...

The second part is to create a second file that will have all of the ingredients and will be renamed with a suffix of "-ingr" and will have Line1 - Line4 added as well. This piece should look something like this...

Line1: Recipe Name
Line2:
Line3: Servings
Line4:
Line5: Ingredient1
Line6: Ingredient2
Line?: Last Ingredient

I have a feeling that a batch file can do this since the recipes always have a blank line between the lines that I have named but I am pretty blank about even dreaming up a solution for this so I thought I might pass this along and see if anyone can help. Thanks.


See More: Batch file to extract certain lines

Report •


#1
January 7, 2009 at 01:25:37
save the following as ExtractLine.bat.
i write it in another batch for reuseability reason.


::ExtractLine.bat [inputfile as %1, outputfile as %2, start as %3, optional end as %4]
@echo off & setlocal disabledelayedexpansion
for %%a in ("%~1" "%~2" "%~3") do if %%a=="" goto :SYNTAX


set /a start=%3+1
if "%~4"=="" (set /a end=0x7fffffff) else set /a end=%4

for /f "skip=%start% tokens=1* delims=[]" %%a in ('find /v /n "" %1') do (
if %%a leq %end% if "%%~b"=="" (echo.>>%2) else echo %%b>>%2
)
endlocal & exit /b 0

:SYNTAX
echo USAGE: %0 [INPUT FILE] [OUTPUT FILE] [START LINE] [optional END LINE]
echo eg: %0 test.txt output.txt 1 4
exit /b 1

here is your main batch.
the first part i understand, to get line 1-4, and then append line nth+2.
the second part is not really clear, dont know which line to which line you want.
anyway, you can modify the following batch to suit your need.


@echo off & setlocal enabledelayedexpansion

if "%~1"=="" echo USAGE: %0 [FILE] [SKIP Nth LINE] & goto :eof
if "%~2"=="" echo USAGE: %0 [FILE] [SKIP Nth LINE] & goto :eof

set f="%~n1-InStr%~x1" & @echo off>!f!

call ExtractLine "%~1" %f% 1 4 && call ExtractLine "%~1" %f% %2+2



Report •

#2
January 7, 2009 at 05:11:31
Hi Reno, wow, it seems you guys really eat and sleep with batch files! lol. I just woke up over here so I missed your replies but thank you for replying. =)

In regards to the second part... that is exactly what makes this whole thing seem like a challenge in my mind... The amount of lines that will have ingredients will always be different... Some recipes may have 3 lines of ingredients while others may have 12... I figured that a batch file could still handle it because there is always a blank line after the ingredient entries... I hope I am not dreaming on this point...

Here is a recipe example...

7 Grain Granola

Servings

3 1/2 Cup whole wheat flour
1 Cup coconut shredded or flake
2 1/2 Cup rolled oats or pecan meal
1 Cup honey or date sugar or sorghum
1/2 Cup sesame seed meat or sunflower
1 Cup oil blended with
1 Cup hot water
1 1/2 Cup rye flour
1 Cup corn meal, fine
1 tbs. salt
1 Cup soy flour
1 Tsp vanilla
1 1/2 Cup wheat germ

Mix dry ingredients together. Add blended liquid ingredients. Rub together with hands to moisten all the flours. Spread on cookie sheets and bake in a slow oven 25O-3OO degree oven for 2 hours or until throughly dry and golden color.
Stir occasionally to prevent burning around edges and to break up large pieces. Store in covered jars.

Delicious served with your favorite cream or nut milk recipe

+++End of First Example++++++++++++

And here is another example...

2 Layer Banana Cake

Servings

1/2 Cup oil
2 3/4 Cup whole wheat pastry flour
1 Cup honey
2 eggs, separated
2½ Tsp cellu or homemade baking powder
1 large mashed banana (3/4 cup)
½ Tsp salt
½ Cup milk, soy

With an electric mixer- Cream oil and honey, add beaten egg yolks. Mix well. Combine milk and banana. Add alternately, beating with dry ingredients to the oil, honey, mixture. Fold in beaten egg whites.

Pour into 2-layer cake pans (lined with wax paper) Bake at 350 for 50 minutes. Remove from pans.

When cool serve with lemon sauce and frosting or cream.

+++++++End of Recipe Examples+++++++

Now here is an example of what I wish this might look like after the batch has "operated" on it....
For Part 1:...

2 Layer Banana Cake

Servings

With an electric mixer- Cream oil and honey, add beaten egg yolks. Mix well. Combine milk and banana. Add alternately, beating with dry ingredients to the oil, honey, mixture. Fold in beaten egg whites.

++++End of Part 1++++++++++++++++++++

And for Part 2...

2 Layer Banana Cake

Servings

1/2 Cup oil
2 3/4 Cup whole wheat pastry flour
1 Cup honey
2 eggs, separated
2½ Tsp cellu or homemade baking powder
1 large mashed banana (3/4 cup)
½ Tsp salt
½ Cup milk, soy

+++++End of Part 2++++++++++++++

..and then these parts need to be saved to a file that will be named using the title (first line) of the recipe and have a suffix of "-instr" added to these file names for Part 1 and a suffix of "-ingr" added to these file names for Part 2.

I hope there is some sort of pattern in this that makes batch filing possible for extracting the data. Thanks for all of your help.

Sorry for the loooonggg post but I couldn't think of any other way to explain this... :(


Report •

#3
January 7, 2009 at 05:39:11

::RECIPE.BAT [FILENAME as %1]
@echo off & setlocal enabledelayedexpansion

if "%~1"=="" echo USAGE: %0 [FILENAME] & goto :eof


set f1="%~n1-instr%~x1" & @echo off>!f1!
set f2="%~n1-ingr%~x1" & @echo off>!f2!


set /a section=1
for /f "skip=2 tokens=1* delims=]" %%a in ('find /v /n "" "%~1"') do (
if "%%~b"=="" set /a section+=1
if !section! leq 2 if "%%~b"=="" (echo.>>%f1% & echo.>>%f2%) else echo %%b>>%f1% & echo %%b>>%f2%
if !section! equ 3 if "%%~b"=="" (echo.>>%f2%) else echo %%b>>%f2%
if !section! geq 4 if "%%~b"=="" (echo.>>%f1%) else echo %%b>>%f1%
)

yum yum, banana cake =)


Report •

Related Solutions

#4
January 7, 2009 at 06:48:28
I will have to send you a piece for sure when this is all done. lol. I will test the batch that you have given and report back in a few minutes...

Report •

#5
January 7, 2009 at 07:13:21
Unfortunately I must be doing something wrong :( but neither one of these batches is working for my recipes today...

Here are the steps that I took.

I copied the contents in your first post from the line that starts with "::Extract line..." to the line that starts with "exit.." and I pasted this into notepad and saved it as a batch file.

I then copied all o the contents of Response number3 and pasted this into notepad and saved it as a different batch file.

I then copied both of these batch files into a Test Directory on my C: drive along with the two sample recipes that I have listed as examples above.

My final step was to run the batch files one after the other... but the recipes simply sat there looking back at me with keen curiosity and did nothing... So I decided to try experimenting a little and I proceeded to insert some blank lines between the entries as it seems to appear in the post since these blank lines had totally disappeared when I copied and pasted the text into notepad. The results of this test were even more disheartening... This time the recipes did in fact do something... About 4 new creatures purporting as files appeared in my test folder but they had no extensions and the contents of these "files" were blank or a few garbled characters...

Please advise if there is something that I have done incorrectly or if there is something else that I can try. Thanks again.


Report •

#6
January 7, 2009 at 10:07:17
use only the last batch, the first one does not suit your need.
it could be the pre tag i use that make copy & paste so difficult. hope you dont mind to try again, copy & paste the batch below.



::RECIPE.BAT [FILENAME as %1]
@echo off & setlocal enabledelayedexpansion

if "%~1"=="" echo USAGE: %0 [FILENAME] & goto :eof

set f1="%~n1-instr%~x1" & @echo off>!f1!
set f2="%~n1-ingr%~x1" & @echo off>!f2!

set /a section=1
for /f "skip=2 tokens=1* delims=]" %%a in ('find /v /n "" "%~1"') do (
if "%%~b"=="" set /a section+=1
if !section! leq 2 if "%%~b"=="" (echo.>>%f1% & echo.>>%f2%) else echo %%b>>%f1% & echo %%b>>%f2%
if !section! equ 3 if "%%~b"=="" (echo.>>%f2%) else echo %%b>>%f2%
if !section! geq 4 if "%%~b"=="" (echo.>>%f1%) else echo %%b>>%f1%
)


Report •

#7
January 7, 2009 at 10:23:36
I don't mind trying again at all. Thanks for coming back... It was getting lonesome in this forum and I was getting dizzy from refreshing the page to see if there was any new responses. I will answer back in a few moments after I try your new batch recipe. =)

Report •

#8
January 7, 2009 at 10:25:27
This one did not work either. :( The recipes are still peering back at me unchanged.

Report •

#9
January 7, 2009 at 10:38:56
check PM again..

Report •

#10
January 7, 2009 at 11:05:32
Ok I got the PM... I am using MSN to reply... I hope they are cross compatible. :(

Report •

#11
January 7, 2009 at 12:37:38
hmmm well I don't know what happened but I can't find you in my chat window Reno :( ... so if you are still on here, please post any solutions you might find if you can. I can't seem to get this batch recipe to work. If anyone else knows of a solution for this, please help!

Report •

#12
January 7, 2009 at 20:18:11
sorry, it already late at night and i went to sleep yesterday. i'm using windows xp pro and have tested the code above.
i save your banana recipe as banana.txt then use the recipe.bat as follow:
c:\recipe banana.txt

it successfully created 2 files with ingredients & instruction in the folder:
1. banana-instr.txt --> instruction file
2. banana-ingr.txt --> ingredients file

the batch works as follow, it search for blank line & divide banana.txt into 4section or more.
the first 2 section is header. the 3rd section is ingredients, and the others section is instruction. it only works as expected if only one blank line between sections. if more than one blank line, more coding can be added to make it work.

unless i can debug in your system, else i dont know which part of the code went wrong. maybe someone with more experience can help.


Report •

#13
January 7, 2009 at 21:31:19
Hi, Reno! I guess I will have to crawl into these midnight hours to be able to reach you since our time zones are different. :( Oh well... Here is an interesting note... I deleted a space in this line...

if "%~1"=="" echo USAGE: %0 [FILENAME] & goto :eof

So that it would read...

if "%~1"==""echo USAGE: %0 [FILENAME] & goto :eof

...and I renamed the file to the same thing you named it to...and I put the files directly on the C: drive like you did and then I ran the batch again. This time there was a little progress. Two files appeared. One was named -instr and the other was named -ingr. Sadly both of these files were blank and none of them had any extension, so I tried to alter the batch file again in numerous ways but no luck... :( I hope there is a way for it to work. :( Oh by the way I am running this on a 64Bit Vista Home Premium machine. I don't know if that would affect this... Please let me know and I will try it on another box. Thanks again for your help on this.


Report •

#14
January 7, 2009 at 22:31:41
type this code, and post back the debug information so i know which line goes wrong.
i dont mean to try in c:\, try it in c:\test folder
c:\test\recipe banana.txt

::RECIPE.BAT [FILENAME as %1]
@echo off & setlocal enabledelayedexpansion
cls
:0
verify other 2>nul & setlocal enableextensions
if errorlevel 1 echo 0. no enableextensions

:1
echo 1. CMD-%0 %*
if "%~1"=="" echo USAGE: %0 [FILENAME] & goto :eof
:2
echo 2. CMD-%0 %*
if exist "%~1" (echo 2. %1 exist. Proceed..) else echo 2. ERR:%1 not exist

:3
set f1="%~n1-instr%~x1" & @echo off>!f1!
echo 3. created %f1%
if exist %f1% (echo 3. %f1% exist. Proceed..) else echo 3. ERR:%f1% not exist

:4
set f2="%~n1-ingr%~x1" & @echo off>!f2!
echo 4. created %f2%
if exist %f2% (echo 4. %f2% exist. Proceed..) else echo 4. ERR:%f2% not exist

:5
set /a section=1
for /f "skip=2 tokens=1* delims=[]" %%a in ('find /v /n "" "%~1"') do (
echo [SECTION !section!] LINE %%a. %%b
if "%%~b"=="" set /a section+=1
if !section! leq 2 if "%%~b"=="" (echo.>>%f1% & echo.>>%f2%) else echo %%b>>%f1% & echo %%b>>%f2%
if !section! equ 3 if "%%~b"=="" (echo.>>%f2%) else echo %%b>>%f2%
if !section! geq 4 if "%%~b"=="" (echo.>>%f1%) else echo %%b>>%f1%
)

:6
echo Quit..copy and paste the debug info and post in forum
notepad %f1%
notepad %f2%



Report •

#15
January 7, 2009 at 23:34:24
Hi again Reno. I copied and pasted the code that you shared into notepad and saved it as a RecipeDebug.bat file.
I then save it into my test folder and ran it... The cmd screen popped up for a fraction of a second and then it disappeared and that seems to be the end of what happened. Nothing new is seen in the test folder.
I will toy with it some more in about 6 hours when I wake up. Its 2 in the morning and I have been combing the forums all day for this one. :(

Report •

#16
January 7, 2009 at 23:55:54
alas, based on the symtomps, i think i know what is wrong now. if you double click the bat file, it wont work, because you have to run it in command prompt.

in windows xp, not sure about vista, never touch vista until now =P
SOLUTION 1:
-----------
click start button, then select run
type:
cmd
or
command

a dos box will appear, then type:
cd c:\test
recipe banana.txt


SOLUTION 2: (win xp)
----------
1. right click recipe.bat and select create shortcut.
2. copy/cut "shortcut to recipe.bat" file into the following folder "c:\documents and setting\%your user name here%\sendto\"
3. right click on "banana.txt", then select "send to" and then "shortcut to recipe.bat"


Report •

#17
January 8, 2009 at 06:10:55
Hello Reno!! Thanks a gazoolian again. We are making some progress. I loaded it into a cmd window in several mutations... and I finally got one of them to work. =)

Will I have to do this for each recipe? Or can I create another batch file that will load this batch file and perform the operations when the new batch file is double clicked from inside of the recipe folder?

I am posting my cmd error messages for anyone who might be following this project who may find this information useful in the future. This is what worked along with my silly mistakes like forgetting to put quotes around the name of the recipes since the names have spaces. :(

As I think more about it, Reno, maybe this is why the original batch tool was not working correctly. The recipe names have spaces. Could that have something to do with it?

Here is my error log along with my subsequent successful maneuver...

Microsoft Windows [Version 6.0.6001]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.

C:\Users\Designer One>cd C:\Recipe

C:\Recipe>Recipe-Extractor
USAGE: Recipe-Extractor [FILENAME]

C:\Recipe>Recipe-Extractor 2 Layer Banana Cake
File not found - 2

C:\Recipe>Recipe-Extractor.bat [7 Grain Granola.txt]
File not found - [7

C:\Recipe>Recipe-Extractor ["7 Grain Granola.txt]
Grain was unexpected at this time.
C:\Recipe>Recipe-Extractor.bat ["7Grain Granola.txt"]
Granola.txt"]"=="" was unexpected at this time.
C:\Recipe>Recipe-Extractor.bat "7 Grain Granola.txt"

C:\Recipe>

Well let me know if there is a step we can take to make a second batch that can load this one. Thanks again for sticking with me on this. You are really a batch king!


Report •

#18
January 8, 2009 at 07:51:12
Well as daffy as this may be... I tried using a CALL command but of course I have no idea what I was doing so as can be expected, it did not work. Here is what my batch experience could come up with. Please don't laugh.

@echo off
@CALL "Recipe-Extractor.exe" < "*.txt"
cls

Well after pressing on this wonderful batch device a few times, it finally started to sink in that it wasn't working. lol. Anyways... please advise if there is another way. Thanks again.


Report •

#19
January 8, 2009 at 07:56:41
you have to use quotation mark around filename with space.

type: recipe /? for help

::RECIPE.BAT FILE(s) as %*
@echo off & setlocal enabledelayedexpansion

echo "%*"|find "?">nul && goto :SYNTAX || if "%~1"=="" goto :SYNTAX

for /f "tokens=* delims= " %%f in ('dir /b %*^|find /v "-ingr."^|find /v "-instr."') do (

set f1="%%~nf-instr%%~xf" & echo off>!f1!
set f2="%%~nf-ingr%%~xf" & echo off>!f2!

set /a section=1
for /f "skip=2 tokens=1* delims=]" %%a in ('find /v /n "" "%%~f"') do (
if "%%~b"=="" set /a section+=1
if !section! leq 2 if "%%~b"=="" (echo.>>!f1! & echo.>>!f2!) else echo %%b>>!f1! & echo %%b>>!f2!
if !section! equ 3 if "%%~b"=="" (echo.>>!f2!) else echo %%b>>!f2!
if !section! geq 4 if "%%~b"=="" (echo.>>!f1!) else echo %%b>>!f1!
)
echo done %%~f --^> !f1! ^& !f2!
)
pause
goto :eof

:SYNTAX
echo Parse Recipe(s) One or More Files into Ingredients ^& Instructions File
echo.
echo USAGE: %0 FILE_1 FILE_2 FILE_3 FILE_N
echo.
echo eg: %0 *.txt
echo %0 banana.txt "layer cake.txt" "7 Grain Granola.txt"
echo %0 *cake??.*


Report •

#20
January 8, 2009 at 08:51:24
Well I'm glad for you to practice on me today. :) I think your work so far has been great but I guess I'm not the best judge since I'm so clueless in this batch language. lol.

So what is this new batch recipe that you have included in your last post? Is this a new and revised batch recipe that I can double click and it will do everything without me needing to use the "SendTo" option on each recipe?


Report •

#21
January 8, 2009 at 09:11:18
SOLUTION 1:
------------
1. Right click on "Recipe.bat", and select "create shortcut"

2. Right click on "shortcut to recipe.bat" and select property

3. on target text box, add *.txt into end of line.
eg. target box=C:\test\recipe.bat
change it to C:\test\recipe.bat *.txt

4. click on apply then ok button

now you can double-click on "shortcut to recipe.bat" to parse all the txt file.

SOLUTION 2:
----------
add the following code below the setlocal enabledelayedexpansion" code.

if "%~1"=="" %0 *.txt


Report •

#22
January 8, 2009 at 09:33:45
I hope you don't get tired of all these maneuverings... Well after creating the shortcut I have found a rather strange behaviour. When I use the shortcut to slice and dice the instructions and ingredient lists, I end up with a failed result. This is what it looks like...

Sorry but its kind of long... This must be the longest post ever. lol.

++++This is a file named "2 Layer Banana Cake-instr" that the batch file shortcut spit out++++++

Servings

1/2 Cup oil
2 3/4 Cup whole wheat pastry flour
1 Cup honey
2 eggs, separated
2½ Tsp cellu or homemade baking powder
1 large mashed banana (3/4 cup)
½ Tsp salt
½ Cup milk, soy

With an electric mixer- Cream oil and honey, add beaten egg yolks. Mix well. Combine milk and banana. Add alternately, beating with dry ingredients to the oil, honey, mixture. Fold in beaten egg whites.

Pour into 2-layer cake pans (lined with wax paper) Bake at 350 for 50 minutes. Remove from pans.

When cool serve with lemon sauce and frosting or cream.




7 Grain Granola
ECHO is off.
Servings
ECHO is off.
3 1/2 Cup whole wheat flour
1 Cup coconut shredded or flake
2 1/2 Cup rolled oats or pecan meal
1 Cup honey or date sugar or sorghum
1/2 Cup sesame seed meat or sunflower
1 Cup oil blended with
1 Cup hot water
1 1/2 Cup rye flour
1 Cup corn meal, fine
1 tbs. salt
1 Cup soy flour
1 Tsp vanilla
1 1/2 Cup wheat germ

7 Grain Granola
ECHO is off.
Servings
ECHO is off.
Mix dry ingredients together. Add blended liquid ingredients. Rub together with hands to moisten all the flours. Spread on cookie sheets and bake in a slow oven 25O-3OO degree oven for 2 hours or until throughly dry and golden color.
Stir occasionally to prevent burning around edges and to break up large pieces. Store in covered jars.
ECHO is off.
Delicious served with your favorite cream or nut milk recipe
ECHO is off.
ECHO is off.
ECHO is off.

7 Grain Granola

Servings

3 1/2 Cup whole wheat flour
1 Cup coconut shredded or flake
2 1/2 Cup rolled oats or pecan meal
1 Cup honey or date sugar or sorghum
1/2 Cup sesame seed meat or sunflower
1 Cup oil blended with
1 Cup hot water
1 1/2 Cup rye flour
1 Cup corn meal, fine
1 tbs. salt
1 Cup soy flour
1 Tsp vanilla
1 1/2 Cup wheat germ

Mix dry ingredients together. Add blended liquid ingredients. Rub together with hands to moisten all the flours. Spread on cookie sheets and bake in a slow oven 25O-3OO degree oven for 2 hours or until throughly dry and golden color.
Stir occasionally to prevent burning around edges and to break up large pieces. Store in covered jars.

Delicious served with your favorite cream or nut milk recipe




7 Grain Granola

Servings

3 1/2 Cup whole wheat flour
1 Cup coconut shredded or flake
2 1/2 Cup rolled oats or pecan meal
1 Cup honey or date sugar or sorghum
1/2 Cup sesame seed meat or sunflower
1 Cup oil blended with
1 Cup hot water
1 1/2 Cup rye flour
1 Cup corn meal, fine
1 tbs. salt
1 Cup soy flour
1 Tsp vanilla
1 1/2 Cup wheat germ

Mix dry ingredients together. Add blended liquid ingredients. Rub together with hands to moisten all the flours. Spread on cookie sheets and bake in a slow oven 25O-3OO degree oven for 2 hours or until throughly dry and golden color.
Stir occasionally to prevent burning around edges and to break up large pieces. Store in covered jars.

Delicious served with your favorite cream or nut milk recipe




@echo off
@START Recipe-Extractor.exe < "*.txt"
cls

+++End of Batch File Spit Out++++++++++++


+++This is a file named "2 Layer Banana Cake-instr-ingr" that the batch file shortcut spit out+++++




2 Layer Banana Cake


+++End of Batch File Spit Out+++++++++++

As you can see, something went wrong but I am not sure what.

This is the Target Path of the shortcut that I created...
C:\Test\Recipe-Extractor.bat *.txt
and this is the "Start In" Directory...
C:\Test

The "SendTo" option does work but for a lot of recipes that could be sort of problematic. :( Let me know if you can cook up any more ideas. Thanks again Reno.


Report •

#23
January 8, 2009 at 09:40:44
I also added the other code below the line in the original batch file but it is exhibiting the same behavior.

Report •

#24
January 8, 2009 at 20:42:25
i've double cross check everything and everything is ok. so at the least this i suggest you to do this:

- start from scrath.
- create new folder eg. c:\TEST2
- delete the previous folder eg c:\test
- delete all the previuos .bat file.

copy the batch from post #19 then pick only one of the solution on post #21.


Q:+++This is a file named "2 Layer Banana Cake-instr-ingr" that the batch file shortcut spit out+++++
A:it could not be happened! as the batch has a error check on this. unless your file has no extension.


Q:7 Grain Granola
ECHO is off.
Servings
ECHO is off.

A:the part where the code is echo.>> make sure there is a dot right after the echo and there shouldnt be any space between them.


Q:@echo off
@START Recipe-Extractor.exe < "*.txt"

A:bat file is not an exe (executable).


Q:The "SendTo" option does work but for a lot of recipes that could be sort of problematic.
A:tips on "SendTo", yes you can, you can select all the txt files by left click and then drag, then click on one of the file and select "sendto". or you could selectively select the txt file by holding CTRL-Left click on each of the file(s).

notes: you need to update the shortcut to the latest batch file as of post#19. as the first batch on post #1 or #6 only accepts single file.


Report •

#25
January 9, 2009 at 00:22:30
Hi Reno! It's working great now!!!! Thank you Thank you Thank you!!! I think this qualifies as one of the best discussions of all time and in the minds of some it would be the greatest display of my batch file stupidity...lol.

I will post the details of the working batch file now and the steps that I took to set it up just in case some poor soul is just as lost in the world of batch files as I am... I doubt it, but oh well here it is anyway...

Step 1: Assume that your understanding of batch files is actually a lot worse than you thought.

Step 2: Open notepad and paste into the open document the entire contents of the batch file shared any batch expert (Like Reno, or IVO, and I am sure countless others) here on Computing.net. For our current recipe batch this is found in POST 19. Be careful not to add any extra lines or spaces and make sure that you follow the instructions that Reno has shared in POST 24... I think that might make a difference sometimes... Ask the experts....

Step 3: Go the the File menu and select "Save As" instead of "Save" and enter the name that you want to give to your new batch file.

Step 4: Select the "Save as Type" menu and choose "All Files"

Step 5: Make sure that you are saving your batch file in the location recommended by the batch experts (This is pretty important since the code in the batch file often points to a certain folder). If the folder does not exists then create it. When you are done Press Save.

Step 6: When the file has been saved, close notepad.

Step 7: Follow Solution 1 in POST 21 or if you a more advanced batch techie then try Solution 2. If you use Solution 1, remember to insert one blank space after the text that is currently in the "Target" field and before you add the characters *.txt

Step 8: Now you can paste your recipes from anywhere on the planet into the folder where you have saved your batch file as long as they are in the format shown and/or described in this very long discussion. When you double click on the shortcut that you just created it will start the batch file which will separate the ingredients from the directions in the recipe and create two seperate files with the suffix of -ingr and -instr added to the file names. -ingr will be added to the name of the file that will now have the ingredients list and -instr will be added to the name of the file with the instructions.

Step 9. Enjoy one of the greatest recipe splitter batch tool ever and may your days be filled with recipe splittings. =)

I can't thank you enough for your help in this Reno and I hope that some day I might be able to understand these batch files enough to have a chance to be as patient in helping others as you have been in helping me.


Report •


Ask Question