Rename all subtitles files with the same name of mp4 files in same folder

paste -d: <(ls -1 *.mp4) <(ls -1 *.srt) | while read line; do movie="${line%%:*}"; subtitle="${line##*:}"; mv "${subtitle}" "${movie%.*}.srt"; done
Use this command if you want to rename all subtitles for them to have the same name as the mp4 files. NOTE: The order of "ls -1 *.mp4" must match the order of "ls -1 *.srt", run the command bellow to make sure the *.srt files will really match the movies after run this command: paste -d:

5
2020-11-08 02:47:13

What Others Think

Shouldn't `echo $line be `echo "$line" ?
rautamiekka · 11 weeks and 3 days ago
@rautamiekka Actually no, because "echo" command will just print out all the contents of the variable, so it will never run into white space issues. But with the "mv" command we need it. I updated the command to be more reliable with white space in file names. I added the quotes anyway Best ;)
ricardofunke · 11 weeks and 2 days ago
We actually don't need no "echo" here... =/
ricardofunke · 11 weeks and 2 days ago
Tried this and deleted the subs from the folder. Fortunately, it was just 1 file but still.
Moltke · 11 weeks ago
This so helpful for me now can easily convert the names of file and can exist different mp4 files with the same name Ecommerce web development dubai
Faisal · 11 weeks ago
It does work! Thanks a lot for this! SEO companies Tampa
brielleluna · 10 weeks and 6 days ago
this and deleted the subs from the folder. Fortunately, it was just [url=http://www.surecleanonline.co.uk/]surecleanonline.co.uk[/url] . [url=http://www.clearanceworld.org.uk/]clearanceworld.org.uk[/url] . [url=http://www.carpetcleaningproductorlando.us/]house clearances[/url] . [url=https://thefrisky.com/choosing-right-biohazard-clean-service/]biohazard cleaning[/url]
saeed20 · 10 weeks and 5 days ago
guitar lessons spokane Wow! I did not know you can use ipad that way! This is interesting
yeoyeo · 10 weeks and 4 days ago
I really loved reading your blog. It was very well authored and easy to undertand. Unlike additional blogs I have read which are really not tht good. I also found your posts very interesting. In fact after reading. I had to go show it to my friend and he ejoyed it as well! ????
KayGasaway · 10 weeks and 3 days ago
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. HOT MEN CAPS Mercado Livre
hiknigarde · 10 weeks and 2 days ago
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. best climber machine
KayGasaway · 10 weeks and 2 days ago
This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform! ?????
KayGasaway · 9 weeks and 6 days ago
howdy, your websites are really good. I appreciate your work. SILDENAX
hiknigarde · 9 weeks and 4 days ago
This particular papers fabulous, and My spouse and i enjoy each of the perform that you have placed into this. I’m sure that you will be making a really useful place. I has been additionally pleased. Good perform! ?????
KayGasaway · 9 weeks and 2 days ago
great! works well. thanks for this fencingwichitaks.com
looneyhans · 9 weeks ago
The book has a lot of knowledge, but not everyone wants to spend time writing an essay, and for this, I recommend you a wonderful site https://papernow.org/book-reports that will help you write any written work.
Shouressunt · 8 weeks and 5 days ago
I'm constantly searching on the internet for posts that will help me. Too much is clearly to learn about this. I believe you created good quality items in Functions also. Keep working, congrats! CBD Nugs
KayGasaway · 8 weeks and 5 days ago
this is really good! bathroomremodelboise.com
Killersmile · 8 weeks and 4 days ago
Way to go! Great post thanks ! keep on posting! Seamless gutter installation
Chaddychaddy · 8 weeks ago
This is a very interesting blog post. welldrillingmidlandtx.com/well-maintenance-inspection
keywave110 · 7 weeks and 6 days ago
I love the way you write and share your niche! Very interesting and different! Keep it coming! Order Ayahuasca UK
KayGasaway · 7 weeks and 3 days ago
Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing ????
Emilybacklink · 7 weeks and 2 days ago
I agree with you. This post is truly inspiring. montgomerycountytree.com
keywave110 · 7 weeks and 1 day ago
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. 50% naked
hiknigarde · 6 weeks and 4 days ago
Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. There tend to be not many people who can certainly write not so simple posts that artistically. Continue the nice writing sklepy motoryzacyjne szczecin
KayGasaway · 6 weeks and 3 days ago
You guardians do an astounding web diary, and have some unfathomable substance. Continue doing extraordinary. https://crownhostel.ru
KayGasaway · 6 weeks and 3 days ago
I needed to thank you for this phenomenal read!! I unquestionably adored each and every piece of it. I have you bookmarked your site to look at the new stuff you post. http://198.54.126.216">judi online
KayGasaway · 6 weeks and 3 days ago
Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. landscaping near me
KayGasaway · 6 weeks and 2 days ago
I love significantly your own post! I look at all post is great. I discovered your personal content using bing search. Discover my webpage is a great one as you.I work to create several content this post. Once more you can thank you and keep it create! Enjoy! remax listings decatur tx
KayGasaway · 6 weeks and 2 days ago
Hi there, I found your blog via Google while searching for such kinda informative post and your post looks very interesting for me. discover this info here
KayGasaway · 6 weeks and 1 day ago
This was a shocking post. It has some look at here fundamental data on this subject. produit
KayGasaway · 6 weeks and 1 day ago
Just stopped saving the subs separately as takes too much space and difficult to mach with mp4. At least got me some time to look for cv now review as looking for a job ha ha
ira34 · 6 weeks and 1 day ago
awesome site thanks for this! www.hairextensionsspokanewa.com
looneyhans · 6 weeks ago
I truly value this superb post that you have accommodated us. I guarantee this would be helpful for a large portion of the general population. hong kong tvp
KayGasaway · 6 weeks ago
This was a shocking post. It has some look at here fundamental data on this subject. app developer hong kong
KayGasaway · 6 weeks ago
thanks for this love this breast augmentation omaha ne
looneyhans · 5 weeks and 6 days ago
It is an excellent blog, I have ever seen. I found all the material on this blog utmost unique and well written. And, I have decided to visit it again and again. REDUTROL PREÇO
hiknigarde · 5 weeks and 6 days ago
I just hope that this will work on my end. affordableseoservice.org
ChrisC · 5 weeks and 1 day ago
Hmm. Looks pretty good. Isnt it? fort smith concrete contractors click here
LucilleM · 5 weeks and 1 day ago
Thank you so much for sharing this.. I will try it today. fashion tutorials
diplo777 · 5 weeks and 1 day ago
??? ?????? ?????????? ?????? ? ????????????? ??????????? ???. ??, ??????? ??? ???? ???? ????? ???????? ? ???? ?????. ?????? ? ???? ? ? ?????? ???? ?????) ? ??????? ????? 50 ??. ? ????????? ?? ???????? ? 80 ?? ?? 50 ?? 2 ??????, ??????????? ?? ???????? ??????? ??????.
val11 · 4 weeks and 5 days ago
seo little rock love this soo much!
idasanka · 4 weeks and 5 days ago
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. find" rel="nofollow">http://personeriadebarranquilla.gov.co/?option=com_k2&view=itemlist&task=user&id=3107'>find this
bojokey283 · 4 weeks and 1 day ago
This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. find this http://personeriadebarranquilla.gov.co/?option=com_k2&view=itemlist&task=user&id=3107
bojokey283 · 4 weeks and 1 day ago
Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. industrial Automation
bojokey283 · 2 weeks and 6 days ago
This was really an interesting topic and I kinda agree with what you have mentioned here! coronavirus holbox
bojokey283 · 2 weeks and 5 days ago
home care oakland This is the only site the helped me
yeoyeo · 2 weeks and 5 days ago
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. las vegas carpet cleaning
bojokey283 · 1 week and 6 days ago
Thank you for the information. Foundation Repair Wichita KS
Harvey01 · 14 hours ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: