0

I'd like to create a bat file to add a dash (-) onto the end of multiple files. Edit for clarification- The end of the text body of each document, not the document name.

The files are format .940, but they are openable as normal text docs. The files that need appending have various names, but my intention is to drop them all into a single folder, and run the bat on all the .940 files in the folder.

I'e tried using the script, slightly amended from another answer:

    @echo off
    for %%a in (.940) do type - >> %%a

But that just ends up creating a blank .940 file.. and my knowledge of CMD isn't good enough to get me any further.

Any suggestions on how to proceed?

Thanks,

J McNamara
  • 11
  • 2

1 Answers1

0

Try this:

cd yourfilepath
for %%a in (*.940) do (echo ->> %%a)

The *.940 will list out just the .940 files. and then append the hyphen to the end.

shree.pat18
  • 21,449
  • 3
  • 43
  • 63
  • It worked great, thanks. It also creates a file called "dir", which gets a hyphen each time the file is run! Any idea why? (It's not an issue, just curious) – J McNamara Nov 11 '15 at 11:05
  • Hmm that could be an issue with how I am usingthe dir command. Can you try to remove the phrase 'dir /b' and run it again? – shree.pat18 Nov 11 '15 at 11:14
  • 1
    Magic, that sorted it. Cheers! :) – J McNamara Nov 11 '15 at 11:19
  • 1
    This will actually append a dash plus a space to every output line; you should also please edit your answer concerning the `dir /B` issue mentioned in the other comments... – aschipfl Nov 11 '15 at 18:09