<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bat.bat コメントアウト &#8211; スグブログ</title>
	<atom:link href="https://sugublog.org/tag/bat-bat-%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%82%A2%E3%82%A6%E3%83%88/feed/" rel="self" type="application/rss+xml" />
	<link>https://sugublog.org</link>
	<description>ブログ運営について発信中</description>
	<lastBuildDate>Sun, 18 Feb 2024 10:13:40 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://sugublog.org/wp-content/uploads/2021/07/icon_20210703-min-150x150.png</url>
	<title>bat.bat コメントアウト &#8211; スグブログ</title>
	<link>https://sugublog.org</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【bat基礎】バッチファイルでコメントアウトする方法！【エラー対処法有り】</title>
		<link>https://sugublog.org/bat-commentout/</link>
					<comments>https://sugublog.org/bat-commentout/?noamp=mobile#respond</comments>
		
		<dc:creator><![CDATA[suguru]]></dc:creator>
		<pubDate>Mon, 19 Sep 2022 14:09:37 +0000</pubDate>
				<category><![CDATA[bat]]></category>
		<category><![CDATA[bat.bat コメントアウト]]></category>
		<guid isPermaLink="false">https://sugublog.org/?p=5267</guid>

					<description><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/07/PC007-8-1024x620.jpg" class="webfeedsFeaturedVisual" /></p>batファイルでコメントアウトしたい場合の方法を記入します。 スクリプトを作成する上でコメントアウトは大事ですよね。後から見たら何をしているのかわからなくなったりします。 しかしスクリプトによってコメントアウトのやり方が [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><img src="https://sugublog.org/wp-content/uploads/2021/07/PC007-8-1024x620.jpg" class="webfeedsFeaturedVisual" /></p>
<p><strong>batファイル</strong>で<span class="swl-inline-color has-swl-deep-01-color"><strong><span class="swl-fz u-fz-l">コメントアウト</span></strong></span>したい場合の方法を記入します。</p>



<p>スクリプトを作成する上でコメントアウトは大事ですよね。後から見たら何をしているのかわからなくなったりします。</p>


<div class="swell-block-balloon"><div class="c-balloon -bln-right" data-col="blue"><div class="c-balloon__icon -square"><img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-src="https://sugublog.org/wp-content/uploads/2021/02/mine_white_002-e1624111291945.png" alt="" class="lazyload c-balloon__iconImg" width="80px" height="80px"><noscript><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/02/mine_white_002-e1624111291945.png" alt="" class="c-balloon__iconImg" width="80px" height="80px"></noscript><span class="c-balloon__iconName">管理人</span></div><div class="c-balloon__body -speaking -border-on"><div class="c-balloon__text">
<p>複数人で開発する場合など共有の為にもコメントをきちんと書く事は大事です。</p>
<span class="c-balloon__shapes"><span class="c-balloon__before"></span><span class="c-balloon__after"></span></span></div></div></div></div>


<p>しかし<span class="swl-marker mark_yellow">スクリプトによってコメントアウトのやり方が違う</span>ので毎回忘れてしまう事もあります。</p>



<p>そこで今回はwindowsで一番簡単に使用できる<strong><span class="swl-inline-color has-swl-deep-01-color"><span class="swl-fz u-fz-l">batファイルでのコメントアウトのやり方</span></span></strong>を共有します。</p>



<p>また<strong>複数行コメントアウトしたい場合</strong>などの方法も書いておきます。</p>



<p>batファイルを作成する時は未来の自分の為に、コメントアウトで説明文をきちんと書いておきましょう。</p>



<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-9330904718533231" data-ad-slot="6086594686"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">batファイルでコメントアウトする方法</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="576" src="https://sugublog.org/wp-content/uploads/2021/08/script_0809-1-1024x576.jpg" alt="スクリプト" class="wp-image-3869" srcset="https://sugublog.org/wp-content/uploads/2021/08/script_0809-1-1024x576.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/08/script_0809-1-300x169.jpg 300w, https://sugublog.org/wp-content/uploads/2021/08/script_0809-1-768x432.jpg 768w, https://sugublog.org/wp-content/uploads/2021/08/script_0809-1.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>batファイルでコメントアウトする方法を書いておきます。</p>



<div class="swell-block-capbox cap_box is-style-onborder_ttl"><div class="cap_box_ttl"><span>batでコメントアウトする方法３選</span></div><div class="cap_box_content">
<ul class="wp-block-list">
<li>remでコメントアウトする</li>



<li>:でコメントアウトする</li>



<li>::でコメントアウトする</li>
</ul>
</div></div>



<h3 class="wp-block-heading">「rem」でコメントアウトする方法</h3>



<p>バッチファイルで良く使用するのがremコマンドです。REMと大文字で書いても問題ありません。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-c" data-lang="C"><code>rem コメント
REM　コメント</code></pre></div>



<p>基本的にはこのコマンドでコメントする事がほとんどです。</p>



<p><span class="swl-inline-color has-swl-deep-01-color"><strong><span class="swl-marker mark_orange">特に問題なければremコマンドを使用しましょう！</span></strong></span></p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/07/analytics-6-300x200.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/bat-rem-meen-and-use/">【bat基礎】remの意味と使い方を教えます！初心者向けの記事になります！</a>
						<span class="p-blogCard__excerpt">batファイルでremという文字を見かけるけど、どういった意味があるのでしょうか？ どのような時に使用するのでしょうか？使い方は？ といった疑問の声がありましたので&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h3 class="wp-block-heading">「:」でコメントアウトする方法</h3>



<p>「:」コロンを使用してもコメントアウト出来ます。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-c" data-lang="C"><code>:　コメント</code></pre></div>



<p>コロンでも出来ます。しかし「goto」コマンドでラベルが付いた箇所の行に移動するコマンドがありますが、その宛先でも「:」が使用される為、混乱を招く恐れがあります。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/11/Server_20211109-10-300x153.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/bat-goto/">【bat】バッチファイルでgotoを使い、好きな位置まで移動する方法</a>
						<span class="p-blogCard__excerpt">batファイルで好きな位置まで移動できると色々と便利です。 そんな事出来ないと思っていませんか？ 「goto」コマンドを使用すれば以外と簡単に可能だったので、ここに覚&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p class="is-style-icon_bad">「:」はあまり使用しない方が良いでしょう。</p>



<p>その解決策としてあるのが「::」を使用する方法です。</p>



<h3 class="wp-block-heading">「::」でコメントアウトする方法</h3>



<p>「::」コロン２つでもコメントアウトになります。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-c" data-lang="C"><code>::　コメント</code></pre></div>



<p>こちらもあまり使用しませんが、「:」を使用するぐらいなら「::」を使用しましょう！</p>



<h2 class="wp-block-heading">batファイルで複数行コメントアウトする方法</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="683" src="https://sugublog.org/wp-content/uploads/2021/11/script_1114-1024x683.jpg" alt="スクリプト" class="wp-image-4504" srcset="https://sugublog.org/wp-content/uploads/2021/11/script_1114-1024x683.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/11/script_1114-300x200.jpg 300w, https://sugublog.org/wp-content/uploads/2021/11/script_1114-768x512.jpg 768w, https://sugublog.org/wp-content/uploads/2021/11/script_1114.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p><strong>複数行コメントアウト</strong>したい場合もあると思います。</p>



<p>他の言語であれば複数行コメントアウトする方法がありますが<span class="swl-bg-color has-swl-deep-01-background-color"><span class="swl-fz u-fz-l">batにはありません。</span></span></p>



<p>なので<strong><span class="swl-marker mark_orange">すべての行に「rem」を使用</span></strong>しましょう。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-c" data-lang="C"><code>rem 複数行
rem コメントアウト
rem したい</code></pre></div>



<h2 class="wp-block-heading">batファイルでコメントアウトを確認してみよう</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="454" src="https://sugublog.org/wp-content/uploads/2021/07/analytics-7-1024x454.jpg" alt="analystics" class="wp-image-3693" srcset="https://sugublog.org/wp-content/uploads/2021/07/analytics-7-1024x454.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/07/analytics-7-300x133.jpg 300w, https://sugublog.org/wp-content/uploads/2021/07/analytics-7-768x340.jpg 768w, https://sugublog.org/wp-content/uploads/2021/07/analytics-7.jpg 1200w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>では本当にコメントアウトできるか確認しましょう！</p>



<p>batファイルを作成して以下のコマンドを書きましょう！</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-c" data-lang="C"><code>rem echo コメント１ &gt;&gt; bat_commentout.txt
echo コメントの書き方１は「rem」&gt;&gt; bat_commentout.txt

: echo コメント２ &gt;&gt; bat_commentout.txt
echo コメントの書き方２は「:」&gt;&gt; bat_commentout.txt

:: echo コメント３ &gt;&gt; bat_commentout.txt
echo コメントの書き方３は「::」&gt;&gt; bat_commentout.txt</code></pre></div>



<h3 class="wp-block-heading">コメントするコマンドの説明</h3>



<p>すべての行に「echo」コマンドを使用して表示させるようにします。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/07/html-007-2-300x225.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/bat-base-echo/">【bat基礎】バッチファイルのechoで文字列表示する！エラー対処法あり</a>
						<span class="p-blogCard__excerpt">batファイルで「echo」の使い方を今回は行います。 「echo」コマンドは指定の文字列を標準出力に表示する事が出来るコマンドです。 ただ文字列を表示するだけでなく、フ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>batファイルをダブルクリックでも確認できるようにリダイレクト「&gt;&gt;」でファイルに書き出ししています。</p>



<p>batファイルを実行したらbatと同じフォルダに「bat_commentout.txt」ファイルが作成されて追記されるはずです。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/08/DB0804-3-300x210.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/bat-file-create/">【bat基礎】バッチでファイルを簡単に作成する方法！全３種類ご紹介</a>
						<span class="p-blogCard__excerpt">batファイルでファイルを作成する方法をお伝えします。 ファイルを何個も作成する場合に、batで行えば楽に業務を遂行する事が可能です。 batでファイルを簡単に作成する&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h3 class="wp-block-heading">batファイルでコメントアウト出来ているか確認</h3>



<p>batファイルをダブルクリックして実行してみましょう。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/07/analytics-2-300x157.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/bat-execution/">【bat】バッチを実行する方法！実行できない時の対処法などをご紹介</a>
						<span class="p-blogCard__excerpt">batファイルが既にありそれを実行してと言われたけど、どうやって実行すればわからない人の悩みに答えます。 またbatを実行しようとしたけど、できなかった時の原因と対&#8230;</span>					</div>
				</div>
			</div>
		</div>


<p>同じフォルダに「bat_commentout.txt」ファイルが作成されており、中身を見ると以下になっています。</p>



<div class="hcb_wrap"><pre class="prism line-numbers lang-plain"><code>コメントの書き方１は「rem」
コメントの書き方２は「:」
コメントの書き方３は「::」</code></pre></div>



<p>コメントアウトしたい行は表示されていない事が確認出来ます。</p>



<p>成功しています。</p>



<p class="is-style-icon_bad">コメントだけでなくコマンド自体も表示される場合は、バッチファイルの1行目に「@echo off」を入れましょう。</p>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/12/PC教室20211216-8-300x229.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/bat-echo-off/">【bat基礎】バッチで「@echo off」の意味や効果とは？</a>
						<span class="p-blogCard__excerpt">batファイルの初めに「@echo off」という記載があると思いますが、この意味は何でしょうか？ なんの効果があるのでしょうか？「@echo off」が無ければどうなるのでしょ&#8230;</span>					</div>
				</div>
			</div>
		</div>


<h2 class="wp-block-heading">batファイルでコメントが文字化けしている時の対処法</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="792" src="https://sugublog.org/wp-content/uploads/2021/07/clash-1024x792.jpg" alt="エラー発生" class="wp-image-3586" srcset="https://sugublog.org/wp-content/uploads/2021/07/clash-1024x792.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/07/clash-300x232.jpg 300w, https://sugublog.org/wp-content/uploads/2021/07/clash-768x594.jpg 768w, https://sugublog.org/wp-content/uploads/2021/07/clash-1536x1187.jpg 1536w, https://sugublog.org/wp-content/uploads/2021/07/clash-scaled.jpg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>文字列が文字化けしたり、何も起きない可能性もあります。</p>



<p>文字コードが間違っている可能性があります。</p>



<p>文字コードを変更するには以下の手順で行いましょう！</p>



<div class="swell-block-capbox cap_box is-style-onborder_ttl"><div class="cap_box_ttl"><span>batで文字が表示されない時の対処法</span></div><div class="cap_box_content">
<ol class="wp-block-list">
<li>batファイルを開く</li>



<li>名前を付けて保存をする</li>



<li>文字コードを「SJIS」か「ANSI」にして上書き保存する</li>
</ol>
</div></div>


<div class="swell-block-postLink">			<div class="p-blogCard -internal" data-type="type1" data-onclick="clickLink">
				<div class="p-blogCard__inner">
					<span class="p-blogCard__caption">あわせて読みたい</span>
					<div class="p-blogCard__thumb c-postThumb"><figure class="c-postThumb__figure"><img decoding="async" src="https://sugublog.org/wp-content/uploads/2021/06/kaizen1-2-min-scaled.jpg" alt="" class="c-postThumb__img u-obf-cover" width="320" height="180"></figure></div>					<div class="p-blogCard__body">
						<a class="p-blogCard__title" href="https://sugublog.org/bat-garbled-japanese-characters/">【bat】バッチファイルで日本語が文字化けする原因と解決策</a>
						<span class="p-blogCard__excerpt">バッチファイルを使用していて日本語が文字化けする時はないでしょうか？ その原因と解決策を現役エンジニアの筆者が教えます。一瞬で簡単にできるので試してください。&#8230;</span>					</div>
				</div>
			</div>
		</div>


<script async="" src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle ads" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-9330904718533231" data-ad-slot="6086594686"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>



<h2 class="wp-block-heading">まとめ：batファイルでコメントアウトする方法</h2>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="769" src="https://sugublog.org/wp-content/uploads/2021/07/html-007-2-1024x769.jpg" alt="python" class="wp-image-3623" srcset="https://sugublog.org/wp-content/uploads/2021/07/html-007-2-1024x769.jpg 1024w, https://sugublog.org/wp-content/uploads/2021/07/html-007-2-300x225.jpg 300w, https://sugublog.org/wp-content/uploads/2021/07/html-007-2-768x577.jpg 768w, https://sugublog.org/wp-content/uploads/2021/07/html-007-2-1536x1153.jpg 1536w, https://sugublog.org/wp-content/uploads/2021/07/html-007-2-scaled.jpg 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>まとめておきます。</p>



<div class="swell-block-capbox cap_box is-style-onborder_ttl"><div class="cap_box_ttl"><span>batでコメントアウトする方法３選</span></div><div class="cap_box_content">
<ul class="wp-block-list">
<li>remでコメントアウトする</li>



<li>:でコメントアウトする</li>



<li>::でコメントアウトする</li>
</ul>
</div></div>



<p>「rem」を使用しましょう！「REM」でも良いです。</p>



<p>「:」を使用するぐらいなら「::」を使用しましょう！</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sugublog.org/bat-commentout/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
