Solved Batch File remaining but only want First 12 characters?

September 21, 2015 at 09:05:47
Specs: Windows 7
Here is the basic batch file, how do I change it to only capture the 1st 12 instead of the whole file name?

@echo off
pushd "Folder"
for /d %%D in (*) do (
for %%F in ("%%~D\*") do (
for %%P in ("%%F\..") do (
ren "%%F" "%%~nxP_%%~nxF"
)
)
)
popd


See More: Batch File remaining but only want First 12 characters?

Report •


#1
September 21, 2015 at 19:36:08
✔ Best Answer
Not tested fully, but seemed to work ok:

::-------- begin batch
@echo off
pushd "Folder"
for /d %%D in (*) do (
for %%F in ("%%~D\*") do (
call :xx "%%~nxF" "%%~D"
)
)
popd
goto :eof

:xx
set t=%~1
set t=%t:~0,12%
echo ren "%~2\%~1" "%~2_%t%"
::----- end batch


Report •

#2
September 22, 2015 at 07:49:34
Tried it and it didn't work...humm. I am new to writing batch files and was hoping i could edit the first one to do what i want it to do. Thanks for your help.

Report •

Related Solutions


Ask Question