Solved

Command Line Rename files with # sign in the name.

Posted on 2011-03-03
3
397 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
  • 2
3 Comments
 
LVL 83

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

22 Experts available now in Live!

Get 1:1 Help Now