I'd like to use Power Shell or a batch file to rename several files in a folder based on a list in a text file. Essentially I want to append the file names with the author's last names which I have stored in a separate text file. I've seen similar problems where people want to recursively rename files but they are always using a generic common appending element like adding an underscore or pre-pending with folder name, etc.
Any of the above are likely workable solutions with just a little tweaking but the simplest thing to do was to simply create one text file with each row containing "the current filename" You can delete the pause line once you get it tweaked and running correctly.
If you have a large folder with many files names you can get them in a text file by running a batch file with the following line.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. How to batch rename files in a directory from a list of names in a text file Ask Question. Asked 8 years, 1 month ago. Active 4 years, 1 month ago. Viewed 18k times. Improve this question.
Community Bot 1 1 1 silver badge. I don't know anything about Python. Thanks Paul, I'll start looking into that unless someone comes up with a better suggestion. Add a comment. Active Oldest Votes. Get-Content -Path filenames. Improve this answer. Booga Roo Booga Roo 1, 1 1 gold badge 21 21 silver badges 26 26 bronze badges. PowerShell's fun and all, but you don't need it here. TessellatingHeckler TessellatingHeckler This gave me a workable solution!
Thank you so much! John Dorian John Dorian 1, 1 1 gold badge 18 18 silver badges 28 28 bronze badges. I did this and ran it, but saw no output. Shadotek no part of it prints output, are the files there though? That's what I mean. They should have been created in the same directory, right? I didn't see anything. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Making Agile work for data science. Stack Gives Back Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related Hot Network Questions. Question feed. Taymon Taymon 2 2 gold badges 8 8 silver badges 19 19 bronze badges.
Super, you learn something new every day. Revision history can be a great tool for learning, but much of that depends on detailed summaries. If you don't need the undo file the following code is enough. Vijay Vijay 6, 3 3 gold badges 13 13 silver badges 31 31 bronze badges.
Do not parse ls. This does not work. I have a duel boot with Ubuntu Most of my files and folders have spaces in names. I am not a professional but I think replacing the spaces does the trick. I am using and this code works perfectly well for all the photos videos etc except for your example of new line and may be other similar expressions.
Ah, yes because awk splits on spaces. Aside from that awk bit however, you'd be much better off using my loop overall, which does handle spaces very well, dual boot or no dual boot.
Changed as suggested.
0コメント