Solved

Command Line Rename files with # sign in the name.

Posted on 2011-03-03
3
456 Views
Last Modified: 2012-05-11
Some dufus named a bunch of files with #1, #2, #3 and it makes working with them programmatically a bit challenging. My DOS skills have gone really dull and they were not exactly ginsu to begin with.


How do I rename all files with this naming convention:

web_4.2. 2006 Aloha #5.JPG

to

web_4.2. 2006 Aloha 5.JPG (be nice to rename the " " to underscores too but I think I can figure dat one out...)


I tried: ren *#*.* to *.* but that didn't work ( no kidding ) but I had to try it.
0
Comment
Question by:rawinnlnx9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 500 total points
ID: 35031343
Something like this? It will currently only echo the rename commands it would otherwise run; remove the capitalized ECHO to run it for real:
@echo off
setlocal enabledelayedexpansion
for %%a in (*.jpg) do (
  set OldName=%%~nxa
  set NewName=!OldName:#=!
  set NewName=!NewName: =_!
  if /i not "!OldName!"=="!NewName!" ECHO ren "%%a" "!NewName!"
)

Open in new window

0
 
LVL 9

Author Comment

by:rawinnlnx9
ID: 35031447
Excellent!!! I love this place. I spend my time helping others and they spend their time helping me. What a perfect system.

Thanks a bunch. All points are yours for sure.
0
 
LVL 9

Author Closing Comment

by:rawinnlnx9
ID: 35031453
The dude is an expert for certain.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 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