this post was submitted on 21 Jul 2026
13 points (93.3% liked)

Linux

66581 readers
96 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 7 years ago
MODERATORS
 

Ik I can use grep to find filenames with specific characters and then print that to a list but idk how to utilize said list to rename. I found another solution which's using mv but couldn't figure out how to make it work w subdirectories. I think using both grep and mv in unison's the answer just idk how to do it. plz halp

you are viewing a single comment's thread
view the rest of the comments
[–] HaraldvonBlauzahn@feddit.org 1 points 2 days ago* (last edited 2 days ago)

Two ways:

  1. Say you want to rename the files Sevilla_big{number}.jpg to Sevilla_small{number}.jpg:

in bash, using the extglob option:

 shopt -s extglob
for f in pics/**/Sevilla_big*.jpg
do 
     mv "${f}" "${f/big/small/}"
done

(If you want to type it in a single line, you need to add semicolons as separators.)

The '"' are only needed if file names contain whitespaces.

  1. Using find:

    find . -name 'Sevilla.*big.jpg' > t

    now, you edit the file named "t" with Emacs or vim so that you duplicate the file names, modify them as you want, and copy them using the copy-rectangle command right to the collumn with the original names. (Vim also offers this functionality, it is super useful to learn!) Delete any names of files you don't want to change. save the result to t.

Then, in bash:

 <t while read a b; do mv $a $b; done

Alternatively, you could also insert the mv command as a first collumn in t, save t and do:

source t

This variant wouldn't work with spaces in filenames.

  1. Bonus option:

Use the mmv command