How do I rename a bunch of recordings using wildcards?

Moderators: Gully, peteru

Post Reply
ETA_2016
Apprentice
Posts: 64
Joined: Thu Aug 27, 2015 04:42
Location: Melbourne

How do I rename a bunch of recordings using wildcards?

Post by ETA_2016 » Thu Jan 28, 2021 23:16

I'm trying to rename a bunch of recordings, the same way (*Album *.* --> *Albums *.*), without having to do each rename separately.

How can I do that? I can't install mmv or rename (no apt command), and mv doesn't work, so what can I do?

Thanks for any help.

prl
Wizard God
Posts: 32703
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: How do I rename a bunch of recordings using wildcards?

Post by prl » Fri Jan 29, 2021 07:49

You can do it in a shell for loop.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

ETA_2016
Apprentice
Posts: 64
Joined: Thu Aug 27, 2015 04:42
Location: Melbourne

Re: How do I rename a bunch of recordings using wildcards?

Post by ETA_2016 » Wed Feb 03, 2021 01:47

prl wrote:
Fri Jan 29, 2021 07:49
You can do it in a shell for loop.
Could you please provide the full command/instructions.

Thanks

User avatar
adoxa
Wizard
Posts: 1490
Joined: Thu Feb 23, 2017 22:58
Location: CQ
Contact:

Re: How do I rename a bunch of recordings using wildcards?

Post by adoxa » Wed Feb 03, 2021 10:07

I believe this will do it:

Code: Select all

for name in *Album\ *; do mv "$name" "${name/Album/Albums}"; done

prl
Wizard God
Posts: 32703
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: How do I rename a bunch of recordings using wildcards?

Post by prl » Wed Feb 03, 2021 10:10

Something like this:

Code: Select all

for fn in *'News '*.*; do
    echo mv "$fn" "${fn/New/Old}"
done
That version prints what would be done:

Code: Select all

mv 20201206 1857 - ABC - ABC News Sunday.eit 20201206 1857 - ABC - ABC Olds Sunday.eit
mv 20201206 1857 - ABC - ABC News Sunday.ts 20201206 1857 - ABC - ABC Olds Sunday.ts
mv 20201206 1857 - ABC - ABC News Sunday.ts.ap 20201206 1857 - ABC - ABC Olds Sunday.ts.ap
mv 20201206 1857 - ABC - ABC News Sunday.ts.cuts 20201206 1857 - ABC - ABC Olds Sunday.ts.cuts
mv 20201206 1857 - ABC - ABC News Sunday.ts.meta 20201206 1857 - ABC - ABC Olds Sunday.ts.meta
mv 20201206 1857 - ABC - ABC News Sunday.ts.sc 20201206 1857 - ABC - ABC Olds Sunday.ts.sc
To make it actually rename the files, change echo mv to mv.

The quoting in the mv command has to be there (the filenames will contain spaces), and has to use double quotes, not single quotes.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

ETA_2016
Apprentice
Posts: 64
Joined: Thu Aug 27, 2015 04:42
Location: Melbourne

Re: How do I rename a bunch of recordings using wildcards?

Post by ETA_2016 » Thu Feb 04, 2021 03:37

adoxa wrote:
Wed Feb 03, 2021 10:07
I believe this will do it:

Code: Select all

for name in *Album\ *; do mv "$name" "${name/Album/Albums}"; done
Thank you adoxa. That's perfect.
prl wrote:
Wed Feb 03, 2021 10:10
Something like this:

Code: Select all

for fn in *'News '*.*; do
    echo mv "$fn" "${fn/New/Old}"
done
That version prints what would be done:

Code: Select all

mv 20201206 1857 - ABC - ABC News Sunday.eit 20201206 1857 - ABC - ABC Olds Sunday.eit
mv 20201206 1857 - ABC - ABC News Sunday.ts 20201206 1857 - ABC - ABC Olds Sunday.ts
mv 20201206 1857 - ABC - ABC News Sunday.ts.ap 20201206 1857 - ABC - ABC Olds Sunday.ts.ap
mv 20201206 1857 - ABC - ABC News Sunday.ts.cuts 20201206 1857 - ABC - ABC Olds Sunday.ts.cuts
mv 20201206 1857 - ABC - ABC News Sunday.ts.meta 20201206 1857 - ABC - ABC Olds Sunday.ts.meta
mv 20201206 1857 - ABC - ABC News Sunday.ts.sc 20201206 1857 - ABC - ABC Olds Sunday.ts.sc
To make it actually rename the files, change echo mv to mv.

The quoting in the mv command has to be there (the filenames will contain spaces), and has to use double quotes, not single quotes.
Thanks prl.

ETA_2016
Apprentice
Posts: 64
Joined: Thu Aug 27, 2015 04:42
Location: Melbourne

Re: How do I rename a bunch of recordings using wildcards?

Post by ETA_2016 » Thu Feb 04, 2021 21:22

I've changed the names using putty, but the changes aren't showing up on the T4's list of recordings. I've restarted the GUI and rebooted the T4, neither of which helped.

What's going on, and how can I get the changes showing in the list of the T4's recordings?

Paul_oz53
Wizard
Posts: 2789
Joined: Sat Jun 13, 2009 02:34
Location: Melbourne

Re: How do I rename a bunch of recordings using wildcards?

Post by Paul_oz53 » Thu Feb 04, 2021 21:33

ETA_2016 wrote:
Thu Feb 04, 2021 21:22
I've changed the names using putty, but the changes aren't showing up on the T4's list of recordings. I've restarted the GUI and rebooted the T4, neither of which helped.

What's going on, and how can I get the changes showing in the list of the T4's recordings?

The filenames displayed in media player are derived from the .meta file. You need to edit each .meta file to amend the displayed names.
__________________________________
Paul
Beyonwiz T4, 2 x U4: FW - 19.3 20211010
Samsung QA85Q80BAWXXY 4K TV
Samsung QA65Q80TAWXXY 4K TV
Samsung HW Q800BXY soundbar
OverlayHD 1.70, IceTV, Foxtel IQ4
2 x Win7 PCs, 2 x Win10 PCs
Denon AVR -X2400H

User avatar
adoxa
Wizard
Posts: 1490
Joined: Thu Feb 23, 2017 22:58
Location: CQ
Contact:

Re: How do I rename a bunch of recordings using wildcards?

Post by adoxa » Thu Feb 04, 2021 21:35

The name in the list comes from the meta file. Assuming Album doesn't occur in the description (or it doesn't matter if it does), try this:

Code: Select all

sed -i "s/Album /Albums /" *Albums\ *.meta

Post Reply

Return to “Hacks & Tricks”