I haven't had to do this for years, but I know it can be done.
How can I search a directory, find every file named minecraft_server.<version>.jar and rename every instance of minecraft_server.* to vanilla-* ?
Ty !
[Solved] Renaming multiple, similar named files at a time via command line...
- MoreBloodWine
- Posts: 40
- Joined: 2021/03/17 08:33:05
[Solved] Renaming multiple, similar named files at a time via command line...
Last edited by MoreBloodWine on 2021/03/22 10:33:13, edited 1 time in total.
Re: Renaming multiple, similar named files at a time via command line...
Code: Select all
ls -1 minecraft_server.*.jar | while read fname ; do
tname=${fname##minecraft_server.}
tname=${tname%%.jar}
mv $fname vanilla-$tname
done
- KernelOops
- Posts: 428
- Joined: 2013/12/18 15:04:03
- Location: xfs file system
Re: Renaming multiple, similar named files at a time via command line...
Code: Select all
rename "minecraft_server" "vanilla-" minecraft_server.*.jar
minecraft_server1.jar
to:
vanilla-1.jar
is that what you want or did I misunderstood?
--
R.I.P. CentOS
--
R.I.P. CentOS
--
- MoreBloodWine
- Posts: 40
- Joined: 2021/03/17 08:33:05
Re: Renaming multiple, similar named files at a time via command line...
I'll have to test it, but you seemed to have gotten what I was saying, basically taking every instance of minecraft_server.* and changing it to vanilla-* of the given folder where my server jars are stored. Will post back when I test it.KernelOops wrote: ↑2021/03/22 10:24:38the above will rename in the current directory files like:Code: Select all
rename "minecraft_server" "vanilla-" minecraft_server.*.jar
minecraft_server1.jar
to:
vanilla-1.jar
is that what you want or did I misunderstood?
- MoreBloodWine
- Posts: 40
- Joined: 2021/03/17 08:33:05
Re: Renaming multiple, similar named files at a time via command line...
That most certainly worked, Ty !KernelOops wrote: ↑2021/03/22 10:24:38the above will rename in the current directory files like:Code: Select all
rename "minecraft_server" "vanilla-" minecraft_server.*.jar
minecraft_server1.jar
to:
vanilla-1.jar
is that what you want or did I misunderstood?
Getting my server panel going again and it helps if I have everything like minded from pre-vanilla to vanilla and craftbukkit.
Re: [Solved] Renaming multiple, similar named files at a time via command line...
For what it's worth check out command line tool mmv in epel.
Cheers,
gostal
Cheers,
gostal
Desktop Dell T5810 Intel(R) Xeon(R) CPU E5-1650 v4 @ 3.60GHz, 72 GB RAM, Radeon Pro WX 7100
CentOS 7.9.2009
CentOS 7.9.2009