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?

ファイル作成

Posted at

@echo off
setlocal enabledelayedexpansion

REM ▼ 1. 今日の日付(YYYY-MM-DD形式)を取得
for /f %%d in ('wmic os get LocalDateTime ^| find "."') do set ts=%%d
set yyyy=%ts:~0,4%
set mm=%ts:~4,2%
set dd=%ts:~6,2%
set today=%yyyy%-%mm%-%dd%

REM ▼ 2. このバッチのあるパスと親フォルダ名を取得
set "currentDir=%~dp0"
set "currentDir=%currentDir:~0,-1%" REM 最後の \ を削除
for %%f in ("%currentDir%") do set "parentDir=%%~nxf"
for %%f in ("%currentDir%..") do set "upperDir=%%~nxf"

REM ▼ 3. フォルダ名作成:「(ひとつ上のフォルダ名)(日付)」
set "folderName=%upperDir%
%today%"

REM ▼ 4. フォルダ作成
mkdir "%currentDir%%folderName%" 2>nul

echo 作成フォルダ: %currentDir%%folderName%
pause

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?