Rename multiple files using script

I found a script here and changed it. It only works for 1 file at a time, not multiple files. How can I get this script to rename multiple files in a specified directory?

@echo off
setlocal enabledelayedexpansion
set X=64
set Y=4
set FOLDER_PATH=c:\temp\renamefiles\files
pushd %FOLDER_PATH%
for %%f in (*) do if %%f neq %~nx0 (
  set "filename=%%~nf"
  set "filename=!filename:~%X%,-%Y%!"
  ren "%%f" "!filename!%%~xf"
)
popd    

      

+3


source to share


1 answer


I don't know what you mean, but this works for me:

ren "path\to\your\folder\*.*" "foo.*"

      



If you run this command, every file, regardless of whether there are files .txt, .png, .foo, .bar, ...

Every file in this folder will be renamed "foo". But if there are, for example, four .png files, there will only be one .png file falling foo.png, because others cannot be renamed when there are other files with the same name already there.

0


source







All Articles