Solved

Batch REN, removing a word from a file with 2 .dots.

Posted on 2009-04-07
1
426 Views
Last Modified: 2012-06-21
Alright, so here's my deal.  I'm not the most profficent with DOS batch commands, but I'm trying to create a scheduled task to handle removing a word from all files in a specific folder daily.

The folder contains files named like this:
ABC0.75gy_white.jpg
DEF1.23AB_white.jpg

I want to remove the _white from all filenames, no matter where it is.

The examples I've found, described below, break when there are two dots in the statement, breaking the delims, I believe.

For what it's worth, the _white word should always be right before the jpg, so if there was a way to remove "_white.jpg" and tack on .jpg, that would work as a solution.

Thanks!

@echo off&for %%f in (*_white*) do call :ProcessFile %%f
goto :eof
:ProcessFile
echo %1
for /F "delims=_. tokens=1,3" %%c in ("%1") do ren "%1" "%%c.%%d"

Open in new window

0
Comment
Question by:Rookerin
1 Comment
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 24091914
@echo off
setlocal EnableDelayedExpansion
for %%F in (*_white*) do (
  set file=%%F
  ren !file! !file:_white.jpg=.jpg!
)

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now