1.

Solve : RENAME?

Answer»

Hi all,

I have a need to run a batch script that renames a file from:

text_abcdefgh_nonvariablestring-DDMMYYY.ext

to

text_abcd_nonvariablestring-DDMMYYY.ext

any thoughts?Seems ok here:

Code: [Select]@echo off
setlocal EnableDelayedExpansion
SET "file=text_abcdefgh_nonvariablestring-DDMMYYY.ext"
for /f "tokens=1,2,* delims=_" %%a in ("%file%") do (
set "abcd=%%B"
echo ren "%%a_%%b_%%c" "%%a_!abcd:~0,4!_%%c"
)
pauseAwesome, worked perfectly. Thanks.

Is there a way to do this without variables? It's just that the simpler I can MAKE the code, the easier it will be for the end USERS of this process to follow what's going on.Quote from: thenoman on October 02, 2013, 05:10:38 AM

Is there a way to do this without variables? It's just that the simpler I can make the code, the easier it will be for the end users of this process to follow what's going on.

What do you mean without variables? Which variable(s) were you thinking of?Quote from: foxidrive on October 02, 2013, 06:14:15 AM
What do you mean without variables?

Gotta be a classic.


Discussion

No Comment Found