Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - rename all files from a directory to a list of files ...

Reply
 
Old 08-25-2007   #1 (permalink)
show3r@gmail.com


 
 

rename all files from a directory to a list of files ...

hi,

what is a script to rename files like

track 01a.mp3
track 02a.mp3
track 03a.mp3
track 04a.mp3
....

to

track 01.mp3
track 02.mp3
track 03.mp3
track 04.mp3

....

i know the rename command rni,
please help

regards


My System SpecsSystem Spec
Old 08-25-2007   #2 (permalink)
Keith Hill


 
 

Re: rename all files from a directory to a list of files ...

<show3r@gmail.com> wrote in message
news:1188069160.537914.135060@r23g2000prd.googlegroups.com...
> hi,
>
> what is a script to rename files like
>
> track 01a.mp3
> track 02a.mp3
> track 03a.mp3
> track 04a.mp3
> ...
>
> to
>
> track 01.mp3
> track 02.mp3
> track 03.mp3
> track 04.mp3
>


This should do the trick:

Get-ChildItem *a.mp3 | foreach { $_.name -replace '(.*?)a\.mp3', '$1.mp3'}

--
Keith

My System SpecsSystem Spec
Old 08-25-2007   #3 (permalink)
Matthias Tacke


 
 

Re: rename all files from a directory to a list of files ...

Keith Hill wrote:
> <show3r@gmail.com> wrote in message
> news:1188069160.537914.135060@r23g2000prd.googlegroups.com...
>> hi,
>>
>> what is a script to rename files like
>>
>> track 01a.mp3
>> track 02a.mp3
>> track 03a.mp3
>> track 04a.mp3
>> ...
>>
>> to
>>
>> track 01.mp3
>> track 02.mp3
>> track 03.mp3
>> track 04.mp3
>>

>
> This should do the trick:
>
> Get-ChildItem *a.mp3 | foreach { $_.name -replace '(.*?)a\.mp3', '$1.mp3'}
>

I've worlds to go to keep up with Keith's pace and expertise, but here is
my try:

foreach($f in (Get-ChildItem *a.mp3))`
{rename-item $f.name ($f.name -replace 'a\.', '.') -whatIf}

If output looks ok, remove the -whatif

or the shorter
foreach($f in (GCI *a.mp3)){rni $f.name ($f.name -replace 'a\.', '.')}

--
Greetings
Matthias
My System SpecsSystem Spec
Old 08-25-2007   #4 (permalink)
show3r@gmail.com


 
 

Re: rename all files from a directory to a list of files ...

On 25 Aug., 23:05, Matthias Tacke <Matth...@Tacke.de> wrote:
> Keith Hill wrote:
> > <sho...@gmail.com> wrote in message
> >news:1188069160.537914.135060@r23g2000prd.googlegroups.com...
> >> hi,

>
> >> what is a script to rename files like

>
> >> track 01a.mp3
> >> track 02a.mp3
> >> track 03a.mp3
> >> track 04a.mp3
> >> ...

>
> >> to

>
> >> track 01.mp3
> >> track 02.mp3
> >> track 03.mp3
> >> track 04.mp3

>
> > This should do the trick:

>
> > Get-ChildItem *a.mp3 | foreach { $_.name -replace '(.*?)a\.mp3', '$1.mp3'}

>
> I've worlds to go to keep up with Keith's pace and expertise, but here is
> my try:
>
> foreach($f in (Get-ChildItem *a.mp3))`
> {rename-item $f.name ($f.name -replace 'a\.', '.') -whatIf}
>
> If output looks ok, remove the -whatif
>
> or the shorter
> foreach($f in (GCI *a.mp3)){rni $f.name ($f.name -replace 'a\.', '.')}
>
> --
> Greetings
> Matthias


thx for your help
regards

My System SpecsSystem Spec
Old 08-25-2007   #5 (permalink)
Keith Hill


 
 

Re: rename all files from a directory to a list of files ...

"Matthias Tacke" <Matthias@Tacke.de> wrote in message
news:faq5jb$mvm$1@news.albasani.net...
> I've worlds to go to keep up with Keith's pace and expertise,


Nonsense. I posted the wrong friggin' snippet (that was my test code -
doh!). What I should have posted was this:

gci *a.mp3 | rename-item -NewName { $_.name -replace '(.*?)a\.mp3',
'$1.mp3'}

That's what I get for trying to answer one more post when I'm getting "the
look" that we should have left for the in-laws 10 minutes ago. :-)

--
Keith

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to list all files under a directory? Vista General
Creating a list of files that have been deleted from or added to a directory PowerShell
Copying files to Program Files directory Vista file management
rename files (lots of files for newbie) PowerShell
cant delete files or rename files Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46