I have the following script that works if I run it from the same directory:
@echo off
for %%i in (*.csv) do (set fname=%%~ni) & call :renameFile
goto :eof
:renameFile
ren "%fname%.csv" "%fname:~13,16%.csv"
goto :eof
What I intend is to execute it from another directory. I have a share with several directories
- Orion (unidad de red)
|-AEMET (directorio)
|-Scripts (directorio)
|-Temporal (directorio)
In Temporal
I have the files that I have to rename, but to have everything better organized I would like the script to be executed from the directory Scripts
.
For this I made the following modification but I can not get it to work.
@echo off
Set "Ficheros=\AEMET\Temporal\*.csv"
for %%i in ("%Ficheros%") do (set fname=%%~ni) & call :renameFile
goto :eof
:renameFile
ren "%fname%.csv" "%fname:~13,16%.csv"
goto :eof
I've tried:
- Removing the bars from the network drive
AEMET\Temporal\
- Calling it from
\Temporal\
But I can not get it to work from another directory.
What am I doing wrong?