Loading ...
Sorry, an error occurred while loading the content.

Re: [BATCH WORLD] howto extract each character from a text file to another text file.

Expand Messages
  • foxidrive
    Did it work for you?
    Message 1 of 7 , Dec 3, 2011
    • 0 Attachment
      Did it work for you?

      On 30/11/2011 12:14, foxidrive wrote:
      > This writes to *.bin and reads from *.txt files.
      >
      >
      > @echo off
      > for /f "delims=" %%a in ('dir "*.txt" /a:-d /o:n /b') do (
      > for /f "delims=" %%b in ('type "%%a"') do call :next "%%b"
      > )
      > cls
      > for /f "delims=" %%a in ('dir *.bin /b') do (
      > for /f "delims=" %%b in ('find /c "%%~na" ^<"%%a"') do echo %%~na = %%b
      > )
      >
      > pause
      > GOTO:EOF
      > :next
      > echo %1
      > set "name=%~1"
      > set "num=-1"
      > :loop
      > set /a num=num+1
      > call set "name2=%%name:~%num%,1%%"
      > if not "%name2%"=="" (
      > >>"%name2%.bin" echo %name2%
      > goto :loop
      > )
      >
      >
      >
      > On 30/11/2011 04:08, batchlover93 wrote:
      >> The original content of the text file i have is only 5 numbers long "17982" and will be always 5 numbers until I reach 100000
      >>
      >> And yes the result will be only one number in each text file
      >>
      >>
      >> --- In batchworld@yahoogroups.com, foxidrive <foxidrive@...> wrote:
      >>>
      >>> So, are you counting numbers or are there alpha characters/control characters as well?
      >>>
      >>> Will the lines be very long?
      >>>
      >>> Will there be only one line per file?
      >>>
      >>>
      >>>
      >>> On 29/11/2011 05:16, batchlover93 wrote:
      >>>>
      >>>>
      >>>> No, not exactly if I have 9876543210 in the text file
      >>>>
      >>>> what I want to achieve is
      >>>>
      >>>> the character 9 go into the 9.txt file
      >>>> the character 8 go into the 8.txt file
      >>>> the character 7 go into the 7.txt file
      >>>> the character 6 go into the 6.txt file
      >>>> the character 5 go into the 5.txt file
      >>>> the character 4 go into the 4.txt file
      >>>> the character 3 go into the 3.txt file
      >>>> the character 2 go into the 2.txt file
      >>>> the character 1 go into the 1.txt file
      >>>> and the character 0 go into the 0.txt file
      >>>
      >>>>
      >>>>
      >>>> --- In batchworld@yahoogroups.com, foxidrive <foxidrive@> wrote:
      >>>
      >>>>>>
      >>>>>> Any help appreciated
      >>>>>> Thanks :)
      >>>>>>
      >>>>>
      >>>>>
      >>>>> What happens if you have
      >>>>>
      >>>>> 987654321
      >>>>>
      >>>>> Does 9 still go into 0.txt file?
      >>>>>
      >>>>
      >>>
      >>>
      >>>
      >>>>> On 28/11/2011 22:16, batchlover93 wrote:
      >>>>>> Greetings,
      >>>>>>
      >>>>>> I'm looking for a batch that can extract each character from a text file to another text file.
      >>>>>>
      >>>>>> Example
      >>>>>>
      >>>>>> content of textfile:
      >>>>>> 0123456789
      >>>>>>
      >>>>>> i want to extract each character to a single file
      >>>>>>
      >>>>>> 0 in 0.txt file
      >>>>>> 1 in 1.txt file
      >>>>>> 2 in 2.txt file
      >>>>>> etc...
    Your message has been successfully submitted and would be delivered to recipients shortly.