Page 1 of 1

Remove [] from file name

Posted: 08 Jul 2013 08:51
by aveit
Hi

I have a number of files in a folder like below:

200002 - [20130708] - Test1
258258 - [20130907] - Test2

Is it possible to remove the [ and ] so i would be left with:

200002 - 20130708 - Test1
258258 - 20130907 - Test2

Many thanks
Paul

Re: Remove [] from file name

Posted: 08 Jul 2013 10:04
by penpen
This could help if the files are in the current directory:

Code: Select all

@echo off
setlocal enableDelayedExpansion
for %%a in (*) do (
  set FILE=%%~a
  set FILE=!FILE:[=!
  set FILE=!FILE:]=!
  echo rename "%%~a" "!FILE!"
)
endlocal
goto:eof

penpen

Re: Remove [] from file name

Posted: 09 Jul 2013 01:13
by foxidrive
If you use ! characters in your filenames, then ask for further help.

Re: Remove [] from file name

Posted: 09 Jul 2013 05:26
by aveit
Works perfectly for [ and ].

Would i be able to adjust this to replace
- page

with

_page

Many thanks
Paul

Re: Remove [] from file name

Posted: 09 Jul 2013 06:23
by Squashman
aveit wrote:Works perfectly for [ and ].

Would i be able to adjust this to replace
- page

with

_page

Many thanks
Paul

Add this to the code.

Code: Select all

set FILE=!FILE:- page=_page!