[완료]초보 batch 파일 만들기

bluesolip의 이미지

안녕하세요.
다음의 문의사항이 있어서 고수님의 도움이 필요합니다.
d드라이브 안에 a, b폴더가 있고 a폴더안에 b.txt, c.exe 파일이 있다고 가정할때
b폴더 batch파일을 만들고 이 batch파일 에서 a\*.txt 스트링을 읽어와서 set string="d:\a\b.txt"라고 저장하고 싶은데요.
이렇게 스트링을 읽어와 저장을 하려면 어떻게 해야 할까요?

고수님의 도움 부탁드려요..

bluesolip의 이미지

덧붙이자면

set string="ls 명령어로 읽어서 *.txt로 뽑은 sting"
이런식으로 string에 저장을 하고 싶습니다.

semmal의 이미지

무슨 말인지 모르겠군요.

다른 사람이 잘 알거라고 생각하고 질문하지 말고, 다른 사람이 자신보다 더 모른다고 생각하고 자세히 설명하면서 질문하는게 좋을 것 같군요.
------------------------------
How many legs does a dog have?

------------------------------
How many legs does a dog have?

bluesolip의 이미지

아 죄송합니다. 아래 다시 써봤어요..

set tool="D:\user\ver\verion1.exe"
기존 배치파일 코드에는 ver\version1.exe 요걸 직접 적었어요.
제가 하고 싶은건..
위 디렉토리에 새로운 버전(D:\user\ver\version2)이 들어가면..
코드에 있는 스트링을 변경해야 하잖아요.
그래서 스트링을 안바꾸고 자동으로 그 디렉토리에서 읽어와서..
set tool="자동으로 읽은 디렉토리및파일명"
을 집어넣고 싶어서 위에 처럼 물어봤습니다.

semmal의 이미지

for /f %%i in (C:\newfile.txt) do @echo set tool=%%i > newfile2.txt

newfile.txt에 있는 내용을 불러서, set tool=... 로 만든다음 newfile2.txt에 저장합니다.

만약 newfile.txt의 내용이 aaa 라면, newfile2.txt의 내용은

set tool=aaa

입니다.

설명을 여전히 이해할 수가 없어서 이걸 원하는건지 모르겠군요.
------------------------------
How many legs does a dog have?

------------------------------
How many legs does a dog have?

bluesolip의 이미지

감사합니다. batch로는 알려주신거 처럼 하면 넘 불편할꺼 같아 perl로 변경하여 해결하였습니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.