ファイルが存在するディレクトリ名とファイルの作成日を取得してファイル名に加えるbatを作成したいです。
イメージは以下のようになります。
ファイル名.txt→ファイル名_ディレクトリ名_YYYYMMDD.txt
例:学校情報.txt→学校情報_大学_20230909.txt
現状作成しているコマンドになります。
@echo off
setlocal EnableDelayedExpansion
REM Get the current directory name
set "dirName=%CD%"
for %%a in ("%dirName%") do set "dirName=%%~nxa"
REM Rename the file
ren "file.txt" "file_!dirName!.txt"