Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
patron0119
- Posts: 8
- Joined: 19 Feb 2013 10:32
#1
Post
by patron0119 » 19 Feb 2013 10:43
Hi, I need help writing a DOS script to change symbols as of '-%#@*&!"? for an underscore (_) in a filename.

or how can I incorporated the below DOS command into a DOS script.
for /f "tokens=* delims= " %i in ('dir /b "*.pdf"') do Set LIST=%i& set LIST | ren "%~fi" "%LIST:'=_%"
-
Squashman
- Expert
- Posts: 4488
- Joined: 23 Dec 2011 13:59
#2
Post
by Squashman » 19 Feb 2013 11:47
I know we have answered this question in the past on the forums so searching for it shouldn't be a problem. But there is a flaw in your question as you cannot use ? or * to name a file in the first place.
-
patron0119
- Posts: 8
- Joined: 19 Feb 2013 10:32
#3
Post
by patron0119 » 19 Feb 2013 12:18
Squashman wrote:I know we have answered this question in the past on the forums so searching for it shouldn't be a problem. But there is a flaw in your question as you cannot use ? or * to name a file in the first place.
Yes, I know. These are files that are named by my clients, they named as they like, and I can't do much about it. The symbols are causing me problems when I process the files in a AIX/UNIX environment.
-
mfm4aa
- Posts: 70
- Joined: 13 Feb 2013 14:02
- Location: Europe
#4
Post
by mfm4aa » 19 Feb 2013 13:33
Code: Select all
@echo off &setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%i in ('dir /b "*.pdf"') do (
Set "LIST=%%~i"
Set "LIST=!LIST:'=_!"
ren "%%~fi" "!LIST!"
)
endlocal
This will not work with
=
Last edited by
mfm4aa on 19 Feb 2013 13:47, edited 1 time in total.
-
Squashman
- Expert
- Posts: 4488
- Joined: 23 Dec 2011 13:59
#5
Post
by Squashman » 19 Feb 2013 13:45
patron0119 wrote:Squashman wrote:I know we have answered this question in the past on the forums so searching for it shouldn't be a problem. But there is a flaw in your question as you cannot use ? or * to name a file in the first place.
Yes, I know. These are files that are named by my clients, they named as they like, and I can't do much about it. The symbols are causing me problems when I process the files in a AIX/UNIX environment.
Well sure you can. I do data processing for a living and we set strict guidelines for how the data files must be received from our clients. They all accommodate or we don't process their data.
I am bit confused that you need a Batch script when you said you are processing the files in a Unix environment.
