0

I have a folder with hundreds of files. I need to rename the files in this folder one by one; but this takes a lot of time. I did some research and found that it can export names from a text file to files in any folder I want. But the videos contained insufficient information for me to implement it.

What I've been able to do so far:

  • I was able to transfer file names to TXT file with CMD command. Note: After exporting the filenames I found some errors in the sorting. You can see the related error in the "Example Files II" section.

Example files I:

Files and their real names.

Example files II:

I exported the file names to txt file with CMD; but the order of the fil names is not the same as in the TXT file with slight differences.

Note: This is not a big problem for now; but I would like to know if there is a way to do the correct sorting.

Export File Names

Example files III:

I batch corrected the filenames with EmEditor. Now I need to automatically replace these names with the files in the folder. Here I don't know how to do this. If anyone can provide practical information on this subject, I would be glad.

Corredted File Names

karenbel
  • 19
  • 4

1 Answers1

1

You can use Powershell and a regular expression to rename files. Go to the folder in Explorer, select Open Windows Powershell on the File menu, and enter the following:

Get-ChildItem *.zip | Rename-Item -NewName { $_.Name -replace '-[0-9]{4}-[0-9]{2}-[0-9]{2}(-[0-9]{2}-[0-9]{2}-[0-9]{2}\-utc)?\.zip$','.zip' }

enter image description here

References:

Yutaka
  • 1,761
  • 2
  • 5
  • 9
  • I executed the command, the names were fixed; but the file type has changed from .zip to "file". – karenbel Sep 12 '21 at 05:45
  • Sorry, you will have to replace with `.zip`. I've updated my answer. – Yutaka Sep 12 '21 at 15:20
  • 1
    You don't need to be sorry. The code worked; and thanks for that. There is something I am wondering about; this code worked for me; but this code will not do what I want when I need bulk renaming in the future. I wonder if you know a way to export names from a text file to files in a folder? In a video I watched, they were doing something through excel... For example: They were entering the new names on one side and the existing names of the files on the other side, and somehow the names were changed with new names. Is something like this possible? – karenbel Sep 12 '21 at 15:45
  • I am not sure which video you watched, but you might want to ask a question on that video site. Alternatively, you might be interested in `PowerToys` - https://learn.microsoft.com/en-us/windows/powertoys/powerrename. – Yutaka Sep 12 '21 at 17:48
  • 1
    I reviewed the link you provided, it's not an app close to what I want; but still good to know. I also analyzed the video I watched a bit. I think after a few applications I will be able to make the bulk changes I want in the future. Thanks again for your help. – karenbel Sep 13 '21 at 09:38