0

I have a host of files in a folder that are named as a string. I've found some information similar to what I'm trying to do here. I am not replacing existing characters in the string. I would just like to add Quote_ to the beginning of each file name. I have about 1500-2000 files that need altering.

Thanks!

1 Answer 1

2

All you need to do is (for current directory):

Get-Childitem | % { Rename-Item $_ "Quote_$_"}

It will add Quote_ to the beginning of every filename in directory you're using cmdlet in.

To ommit files that already have Query_ in their names, we can use simple clause to ommit them before replace:

Get-ChildItem | Where-Object { $_ -NotMatch "Quote_" } | % { Rename-Item $_ "Quote_$_"}
Sign up to request clarification or add additional context in comments.

3 Comments

Some of the files already have the Quote_ character in the name. If I use a for loop, will that work?
You may add a simple Where clause that it should ommit filename that are like Quote_*
I've added additional code so that it ommits filenames containing Quote_. Also, if my answer resolves your problem, please consider marking it as such.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.