0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Windowsのbatでフォルダやテキストファイルを生成する

Last updated at Posted at 2021-10-23

ファイル整理するときに毎回右クリめんどくさいので残しておく
起動
キー入力[a\s]
aでフォルダ、bでテキストを生成する
名前は日付
重複があるとエラーが表示される

@echo off

set name=%~dp0%date:/=%_
set type=a
set /p type="a=フォルダ(デフォルト)、s=テキスト: "

if %type% == a (goto :folder)
if %type% == s (goto :text)

:folder

if exist %name% (
	echo msgbox "重複フォルダがあります",vbInformation,"情報">%~dp0msgbox.vbs
	%~dp0msgbox.vbs
	del %~dp0msgbox.vbs
	exit
)
mkdir %name%
exit

:text

if exist %name%.txt (
	echo msgbox "重複テキストがあります",vbInformation,"情報">%~dp0msgbox.vbs
	%~dp0msgbox.vbs
	del %~dp0msgbox.vbs
	exit
)
copy nul %name%.txt
exit

もしエクセルとかを追加したいときは同じフォルダに空のファイルを作っておく
そしてdとかにキーを割り振ってからこんな感じで行けると思う(拡張子は忘れずに)
copy %~dp0空のファイル %~dp0好きな名前

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?