Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

Batch file renaming (replacing strings) & directory listing

May 6, 2012 4:56AM PDT

Ahhh, this is hard. Well, I need something like this.

I have a bunch of files (~1000) and a text file. Text file has lots of strings like this

"Original name" "New name"

I need a program to look recursively in a specified directory and change all instances of "Original name" to "New name", for both files and folders. The formatting of the text file can be different ofc, I don't care. But it has to be something along "old name" <separator> "new name". Note that "old name" and "new name" aren't a file name by itself, just part of the name of X number of files.

I normally use Bulk Rename Utility, great proggie. But it hasn't got a string replacer. It can just rename entire files from a text file, like this

Original File.mkv|New File.mkv

Doing that for thousands of files is a pain. I've found utilities more or less like the one I need, but they are all paid. I can't convert currency or get money out of the country, so even if I want I can't pay Silly. It has to be a freeware. Any ideas?


Aside that I need something to make a list in a text file of all files in a directory (recursively and files only, not folders). The Windows "dir" command with the "/s" switch (for listing recursively a directory) always appends the full path before the files, even if I use the switch for bare format "/b" (removing the "/s" and leaving "/b" gives only the file names, like I want, but from a single folder). Unless there's a special way of using "dir", it simply doesn't work for me Sad

And now that I think of it, it could be instead something to remove everything behind the first "\" counting from the right (to remove paths from the "dir" list) on all lines of the text file Silly


Any ideas? :-\

Discussion is locked

- Collapse -
Answer
Rd: rename and list
May 6, 2012 5:04AM PDT

For renaming, I think it's best to write own script, either a vbs-script or a powershell-script.

That, of course, should work also for the directory listing. But it might be that you find Karen's directory printer (google that to find it) to do what you want. Or not, you're the best one to tell.

Kees

- Collapse -
I agree.
May 6, 2012 5:40AM PDT

Since they can't buy an app they'll have to create their own.

But it makes you wonder how one could reach a thousand files and one day decide they need renaming. That is, as I use my machine I rename my files, move them to what I want as I use the machine.

This makes the effort take almost no time at all.
Bob

- Collapse -
Answer
Regular Expressions
May 6, 2012 6:54AM PDT

For your file list "Karen's Directory Printer" is a great suggestion, mentioned above.
For your file renaming, have you tried regular expressions? "Bulk Rename Utility" can handle that.
If all else fails have a look at, "PFrank". The learning curve is worth it.

- Collapse -
Thanks Ken. Did you see XKCD on that?
May 7, 2012 2:57AM PDT