Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: [solved] Batch processing text files  (Read 5667 times)

0 Members and 1 Guest are viewing this topic.

Lu

    Topic Starter


    Starter

    [solved] Batch processing text files
    « 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 »

    Salmon Trout

    • Guest
    Re: Batch processing text files
    « 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 »

    smeezekitty

    • Guest
    Re: Batch processing text files
    « 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

    Salmon Trout

    • Guest
    Re: Batch processing text files
    « 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?

    smeezekitty

    • Guest
    Re: Batch processing text files
    « Reply #4 on: August 20, 2009, 03:34:10 PM »
    that would be an error

    Salmon Trout

    • Guest
    Re: Batch processing text files
    « Reply #5 on: August 20, 2009, 03:42:11 PM »
    that would be an error

    Quote
    What i do wrong?

    There may be others

    Lu

      Topic Starter


      Starter

      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...

      smeezekitty

      • Guest
      Re: Batch processing text files
      « Reply #7 on: August 21, 2009, 12:36:50 AM »
      did it work or not?
      i am confused ???   ::)

      Lu

        Topic Starter


        Starter

        Re: Batch processing text files
        « 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.

        Helpmeh



          Guru

        • Roar.
        • Thanked: 123
          • Yes
          • Yes
        • Computer: Specs
        • Experience: Familiar
        • OS: Windows 8
        Re: Batch processing text files
        « 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!
        Where's MagicSpeed?
        Quote from: 'matt'
        He's playing a game called IRL. Great graphics, *censored* gameplay.

        Salmon Trout

        • Guest
        Re: [solved] Batch processing text files
        « 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