Re: Renaming files using wildcards
From: Vincent Fatica (abuse_at_localhost.com)
Date: 09/04/04
- Next message: Ross Durie: "Re: XP-Pro/Norton Problem"
- Previous message: Big D: "XP-Pro/Norton Problem"
- In reply to: Jerry Blake: "Renaming files using wildcards"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Renaming files using wildcards"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Renaming files using wildcards"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 04 Sep 2004 04:40:33 GMT
Here's a one-liner that seems to work here in a folder with 1000 files
(no guarantees).
for /f %f in ('dir /b') do ren "%f" "c_%f"
That is: for each line in the output of the 'DIR /B" command (bare file
names), rename the file with the prefix "c_". I used double quotes to
avoid problems with file names containing spaces.
Try 'FOR /?' for more info on the FOR command
Using wildcards generally won't work. Wildcards cause windows to
enumerate the files in a directory. Using a command like the one below,
it is easy to get CMD.EXE into a loop wherein it keeps finding new files
(the newly renamed ones) and renames them again.
Don't do this: for %f in (*.*) do ren %f c_%f
On Fri, 3 Sep 2004 20:24:19 -0700, "Jerry Blake"
<bbibooks@hawaii.rr.com> wrote:
>I have a folder with many files in it that I want to
>rename with a common prefix. I want to add "c_" to the
>front end of a filename and I want to do that all in one
>fell swoop like this from a run cmd line:
>
>Ren *.* c_*.*
>
>It substitutes c_ for the first 2 characters of the
>existing filename.
>
>I've also tried ren *.* c_ & *.* and ren *.* + *.* and
>they don't work. If this can be done from other than the
>command line, that would be acceptable, as long as I
>don't have to rename each file individually.
>Any ideas?
>
>Jerry
-- - Vince
- Next message: Ross Durie: "Re: XP-Pro/Norton Problem"
- Previous message: Big D: "XP-Pro/Norton Problem"
- In reply to: Jerry Blake: "Renaming files using wildcards"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Renaming files using wildcards"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Renaming files using wildcards"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|