Forrest logo
back to the for tool

for:ai:26703

How to rename files to add the creation date in the file name?
$ for %f in (*.*) do ren "%f" "%~tf_%~nf%~xf"
try on your machine

This command uses a for loop to iterate over all files in the current directory (.) and renames each file by appending the creation date to the original file name. The "%~tf" represents the date format (YYYY-MM-DD), "%~nf" represents the file name, and "%~xf" represents the file extension.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.

Questions that are answered by this command:

  • how to rename files to add the creation date in the file name?
back to the for tool