Solved Removing first characters in a file name

September 16, 2011 at 07:16:58
Specs: Windows XP
Hi!

I have many files with different lengths in the same folder and would like to remove the first 8 characters (from the left) from all of them.

Here are some examples of file names I would like to rename:
SANTOS6_002_100Q_FLSP_2.gif
SANTOS6_008_104Q_STACK.gif
SANTOS6_001_000Q_QCAMP_DEEP.gif

I'm trying using this script but it's not working... :(

echo off

LFNFOR On
REN "* " *.*"
FOR %v IN (*.*) DO REN "%v" %v


Someone there to help me? :)


See More: Removing first characters in a file name

Report •

#1
September 16, 2011 at 09:24:00
✔ Best Answer
In your script there are commands unknown to Windos batch and your question is an issue to be posted in Programming Forum since there is no DOS in XP just NT batch. Anyway here the requested code.

@echo off & setlocal EnableDelayedExpansion
cd /D Your_Folder
for %%j in (SANTOS6_*.*) do (
  set newname=%%j
  set newname=!newname:SANTOS6_=!
  ren "%%j" "!newname!"
)


Report •

#2
September 16, 2011 at 10:24:22
Thank you very much!!

And sorry for the wrong way to post it... my first time here, got a bit confused. And I'm using Linux/Unix with VMWare Player.


Report •
Related Solutions


Ask Question