Home / Software / Computer programming / replace characters "_ " and " . " in file names to space with a batch file
0 Members and 3 Guests are viewing this topic. « previous next »
Pages: 1 2 [3]  All - (Bottom) Print
Author Topic: replace characters "_ " and " . " in file names to space with a batch file  (Read 14220 times)
mioo_sara
Topic Starter
Beginner



Posts: 123


« Reply #30 on: June 02, 2009, 07:30:07 AM »

Quote
just change "*.rar" to "*" for all files.

what about file name dear gh0std0g74? how can  i  replace windows media player in  your script?

i mixed  yours scriptes (Reno --gh0std0g74--devcom)  and made a wonderful program  but still  i am  not satisfied but i think  i should search  more and  more to  turn into  a more experienced programmer
thanks again  for your cooperation

and reno  your program  will  always remove "." from files names even  version exapmle nero v2.12
IP logged
Reno
Hopeful



Thanked: 32
Posts: 323




« Reply #31 on: June 02, 2009, 09:01:24 AM »

and reno  your program  will  always remove "." from files names even  version exapmle nero v2.12

because it only detect '_v'
try this, it will detect 'v[0-9]', i couldnt' find a way to hack a for loop to work with 'set &' trick. and findstr/o doesnt display the offset as intended, so this is the manual way.
Code: [Select]
@echo off & setlocal

for /r %%a in (*.rar) do call:strip "%%a"
goto:eof

:strip
set app=%~n1&set ver=
set app=%app:v0=&set ver=v0%
set app=%app:v1=&set ver=v1%
set app=%app:v2=&set ver=v2%
set app=%app:v3=&set ver=v3%
set app=%app:v4=&set ver=v4%
set app=%app:v5=&set ver=v5%
set app=%app:v6=&set ver=v6%
set app=%app:v7=&set ver=v7%
set app=%app:v8=&set ver=v8%
set app=%app:v9=&set ver=v9%
set app=%app:.= %
set app=%app:_= %
set pad=%app%                           
echo Renaming App : %pad:~,25% Ver : %ver%
ren "%~1" "%app%%ver%%~x1"
IP logged
mioo_sara
Topic Starter
Beginner



Posts: 123


« Reply #32 on: June 02, 2009, 10:27:16 AM »

thanks  dear reno 100% done !!! :) :)
wonderful  what a beautiful algorithm !! thanks man
it can  detect "_" and "." all  over the file names and remains version  and extention
just for a final  request can  you  put folders and subfolders in your program?
it just now check and rename files
thanks
IP logged
Reno
Hopeful



Thanked: 32
Posts: 323




« Reply #33 on: June 03, 2009, 02:13:24 AM »

the following will rename files and folders that contain "v[0-9]" in its name. it wont work if name contains '=' sign.
Code: [Select]
@echo off & setlocal

for /r /d %%a in (*) do call:strip "%%a"
for /r %%a in (*) do call:strip "%%a"
goto:eof

:strip
set app=%~n1&set ver=
set app=%app:v0=&set ver=v0%
set app=%app:v1=&set ver=v1%
set app=%app:v2=&set ver=v2%
set app=%app:v3=&set ver=v3%
set app=%app:v4=&set ver=v4%
set app=%app:v5=&set ver=v5%
set app=%app:v6=&set ver=v6%
set app=%app:v7=&set ver=v7%
set app=%app:v8=&set ver=v8%
set app=%app:v9=&set ver=v9%
set app=%app:.= %
set app=%app:_= %
if /i "%~nx1" neq "%app%%ver%%~x1" (
set pad=%app%                           
echo Renaming App : %pad:~,25% Ver : %ver% Ext : %~x1
ren "%~1" "%app%%ver%%~x1"
)
IP logged
mioo_sara
Topic Starter
Beginner



Posts: 123


« Reply #34 on: June 03, 2009, 06:12:24 AM »

thanks dear RENO :P
folders and files are ok  now thanks for your cooperation
have a nice and good day :)
IP logged
sepgit
Newbie



Posts: 1


« Reply #35 on: September 09, 2009, 10:10:48 PM »

Hello I need some help,
I want to replace letter # with R in evry folder and every file.eg.4676867#565:4676867R565
please help me as soon as posible
IP logged
Pages: 1 2 [3]  All - (Top) Print 
Home / Software / Computer programming / replace characters "_ " and " . " in file names to space with a batch file « previous next »
 


Login with username, password and session length

Old Forum Search | Forum Rules
Copyright © 2010 Computer Hope ® All rights reserved.
Powered by SMF 2.0 RC3 | SMF © 2006–2010, Simple Machines LLC
Page created in 0.082 seconds with 19 queries.