Home / Microsoft / Microsoft DOS / [solved] Batch processing text files
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] - (Bottom) Print
Author Topic: [solved] Batch processing text files  (Read 959 times)
Lu
Topic Starter
Starter



Posts: 3


« on: August 20, 2009, 08:48:22 AM »

Hello,

I'm trying process text files from directory, but i do something in wrong way.

Code: [Select]
@echo off
for %%i IN ('D:\txts\*.txt') do
java -jar D:\java\somefile.jar  -i < %%i > %i_done.txt

It should look like this:
Code: [Select]
java -jar D:\java\somefile.jar  -i inputfile.txt > output_done_file.txt
But, of course it doesn't work it that way. What i do wrong?
« Last Edit: August 21, 2009, 02:25:30 AM by Lu » IP logged
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #1 on: August 20, 2009, 11:03:30 AM »

You missed out the opening and closing parentheses and you may need to  escape the < and > symbols. And I don't know what this

Code: [Select]
%i_done.txt
is meant to be

« Last Edit: August 21, 2009, 02:23:26 AM by Salmon Trout » IP logged


Proud to be European
smeezekitty
Newcomer



Thanked: 44
Posts: 0


« Reply #2 on: August 20, 2009, 02:29:31 PM »

%i_done.txt
is suppose to make
the original name plus _done.txt
so
hello_world.txt
would become hello_world.txt_done.txt
IP logged

Acer extensa 463oz
2 gb ram
160gb hdd
2ghz processor
and desk fan sitting next to it for cooling :)
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #3 on: August 20, 2009, 03:33:33 PM »

%i_done.txt
is suppose to make
the original name plus _done.txt
so
hello_world.txt
would become hello_world.txt_done.txt

Why has it only got one % sign?
IP logged


Proud to be European
smeezekitty
Newcomer



Thanked: 44
Posts: 0


« Reply #4 on: August 20, 2009, 03:34:10 PM »

that would be an error
IP logged

Acer extensa 463oz
2 gb ram
160gb hdd
2ghz processor
and desk fan sitting next to it for cooling :)
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #5 on: August 20, 2009, 03:42:11 PM »

that would be an error

Quote
What i do wrong?

There may be others
IP logged


Proud to be European
Lu
Topic Starter
Starter



Posts: 3


re
« Reply #6 on: August 21, 2009, 12:17:55 AM »

I try to achieve such goal:

Take all text files from input directory and let some java program do it's work.
But this program must have defined in and out.
It works fine with commands:
Code: [Select]
java -jar somefile.jar -i C:\input_dir\file1.txt -o C:\output_dir\file_done.txt
java -jar somefile.jar -i C:\input_dir\file1.txt > C:\output_dir\file_done.txt
I cannot do:
Code: [Select]
java -jar somefile.jar -i C:\input_dir\*.txtbecause output is not specified or produces 0 byte output for *.txt which for me it's useless. I need put processed files into different directory with maybe changed names.
Does the closing parenthesis means:
Code: [Select]
(java -jar D:\java\somefile.jar  -i  %%i  -o %%i_done.txt) I guess not...
IP logged
smeezekitty
Newcomer



Thanked: 44
Posts: 0


« Reply #7 on: August 21, 2009, 12:36:50 AM »

did it work or not?
i am confused ???   ::)
IP logged

Acer extensa 463oz
2 gb ram
160gb hdd
2ghz processor
and desk fan sitting next to it for cooling :)
Lu
Topic Starter
Starter



Posts: 3


« Reply #8 on: August 21, 2009, 02:24:47 AM »

Well, the only thing that works is command in cmd:
Code: [Select]
for %i in (c:\input\*.txt) do java -jar somefile.jar -i %i > %i_done.txtBut if it works in cmd i don't care how to write it in batch file - thanks for all replies.
IP logged
Helpmeh
Egghead



Thanked: 117
Posts: 3,608

Experience: Experienced
OS: Windows XP


Roar.

1
« Reply #9 on: August 23, 2009, 07:56:58 PM »

Well, the only thing that works is command in cmd:
Code: [Select]
for %i in (c:\input\*.txt) do java -jar somefile.jar -i %i > %i_done.txtBut if it works in cmd i don't care how to write it in batch file - thanks for all replies.

Take your code, add
@echo off
on a line above it and paste it into notepad. Save it as myscript.bat and there you go!
IP logged

Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.
Salmon Trout
Sage



Thanked: 546
Posts: 7,952

Computer: Specs
Experience: Beginner
OS: Unknown

1
« Reply #10 on: August 24, 2009, 12:37:54 AM »

Quote
paste it into notepad. Save it as myscript.bat

Don't forget to change %i to %%i
IP logged


Proud to be European
Pages: [1] - (Top) Print 
Home / Microsoft / Microsoft DOS / [solved] Batch processing text files « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.1 seconds with 20 queries.