You are not logged in.

#1 02 Jan 2016 05:55

windows
New Member
Registered: 02 Jan 2016
Posts: 2

rename multiple files

hi,

i have many csv files which renamed though windows explorer. all files renamed sequentially, but how could i remove the parentheses which surrounding the files number. example of the files name  tec (1), tec (2)...

Offline

#2 02 Jan 2016 08:27

Shadow Thief
Member
Registered: 12 Jul 2012
Posts: 205

Re: rename multiple files

Will there be parentheses anywhere besides at the end?

Offline

#3 02 Jan 2016 16:39

windows
New Member
Registered: 02 Jan 2016
Posts: 2

Re: rename multiple files

that is not the answer that i am looking for smile  smile .
if you know any way to get out of the parentheses will be appreciated.

Offline

#4 02 Jan 2016 21:01

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: rename multiple files

I'm going to give you the benefit of the doubt and assume you missed the point.  Shadow Thief wasn't offering an answer, rather asking for information to determine what your requirements are prior to suggesting something.

The point being it's fairly trivial to remove all parentheses from a file name.  However, if the only ones you wish to remove are the ones added at the end by Windows Explorer, it's likely to be a bit more involved.

Assuming you just want them all removed, you could do this, for example:

@echo off
cd /d X:\directory\containing\files
for %%a in (*) do (
  call :rename "%%~a"
)

goto :EOF

:rename

set "name_in=%~1"
set "name_out=%name_in:(=%"
set "name_out=%name_out:)=%"

rename "%name_in%" "%name_out%"

goto :EOF

cmd | *sh | ruby | chef

Offline

Board footer

Powered by