Solved

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

Posted on 2009-04-07
1
417 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 68

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 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

13 Experts available now in Live!

Get 1:1 Help Now