I want to create a bat that takes the name of the directory where the file exists and the creation date of the file and adds it to the filename.
The image would be as follows
File name.txt
→File name_Directory name_YYYYYMMDD.txt
Example file in University
directory:
school_information.txt
Becomes:
school_information_university_20230909.txt
This is the command that is currently being created.
@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"