Rename all files from the directory where you have "u0026" to "and"

Asked

Viewed 374 times

2

I have more than two thousand files with "u0026" in the middle of the names (in this case it would be &) and I need a script that can without php or batch to rename all keeping the original name only replacing this "u0026" with "and"I am using Windows 10 and the directory of all files is the same.

1 answer

2


in python can be?

import os
[os.rename(f, f.replace('u0026', 'e')) for f in os.listdir('.') if not f.startswith('.')]

This script will replace the string 'u0026' with 'and' in all files in the folder that is run.


Powershell also rolls already with W10, runs it in the folder you want to rename the files.

Dir | Rename-Item -NewName {$_.name -replace "u0026","e"}
  • unfortunately no, I don’t have it in the machine

  • 1

    maybe the option with powershell.. look there

  • by power can be, in the "dir" the front of it would have to add the directory, right?

  • The intention to help is good, but it is important to note the tags that are [php] and [batch], or Windows command prompt.

  • 1

    @Laérciolopes I saw the tags, however I offered an option that would be wiser judging that it will run at the OS level. then PHP would be a bit too much for the task at hand. And the python code is beem simpler than bash. Not always what the OP asks is what he needs. We are here to help..

  • @Joãovictor command Dir will list the files for the next command just run it like this in the desired folder.

  • Got it, thank you very much

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.