0

I am trying to rename all the file in a folder using this:

@echo off
setlocal EnableDelayedExpansion
for "%file_path_history%" %%a in (*.*) do (
if not "%~nx0"=="%%a" ren "%%a" "%fullstamp%_%%a"
)

But it returns an error message:

path was unexpected at this time.

I have also tried

ren "%file_path_history%*.*" "%file_path_history%%fullstamp%_*.*"

but it does not work.

Any suggestion?

5
  • Where are set file_path_history and fullstamp?
    – harrymc
    Commented Oct 25, 2022 at 11:13
  • Above; doing the rename on a single file it works correctly, so I assume the problem is not related with those varibale, maybe on their calls/usage...
    – Gimmy88
    Commented Oct 25, 2022 at 11:15
  • May you forgot the /r switch in the for /r...... Commented Oct 25, 2022 at 11:15
  • May you give an example of how the files are currently and how you want them to be? Commented Oct 25, 2022 at 11:45
  • sure: current name is "abc.xlsx", "def.csv" and I want to have "20221025_141500_abc.xlsx", "20221025_141500_def.csv", for all the file in the %file_path_history% folder.
    – Gimmy88
    Commented Oct 25, 2022 at 12:16

1 Answer 1

0

Here is the solution:

@echo off
setlocal EnableDelayedExpansion
cd %file_path_history%
for %%a in (*.*) do (
ren "%%a" "%fullstamp%_%%a"
)

Thanks, Andrea

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .