Looking for help with Bash script to search folders, rename, and output to text file
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Looking for help with Bash script to search folders, rename, and output to text file
Hello all! First post and all that.
I'm hoping some kind-soul can help me out with a bash script.
I'm trying to figure out how to get a script to:
scan folders and sub folders of specified directory for any file with the extension .jpg or .png
minimum folder depth of 3
if only 1 image, rename to Folder.<original extension>
if 0 or more than 1, output folder path to /<user name>/documents/follow-up.txt
if 1 image found & dimensions below 400x400 output to above txt file
if 1 image found & has non-square dimensions, output to above txt file
I've googled as best i can, found tutorials, but i admit; It's all very confusing for me. I don't handle lines of text all too well. Much more of an image person. Down-side to being a graphic designer, i suppose
What it's for:
I'm trying to finally finish cleaning up my music collection, and the album art (or lack thereof) is my final hurdle.
The minimum folder depth is to make it so that only album folders are scanned. My collection is organised as so: /Music/<basic genre>/<artist>/<album>, and i would be launching the script from /music.
Parts of what i can find and understand tell me that i can find the image types with: find / -name ‘.jpg’ -o -name ‘.png’
And i can compare a list of folders with and without the search results with: find ./* -mindepth 3 -type d > albums
diff albums has_art > needs_art
less needs_art
I realise half of the snippets of code i've found are probably laughably wrong, but hey. I'm trying
-mindepth levels
Do not apply any tests or actions at levels less than levels (a
non-negative integer). -mindepth 1 means process all files except
the command line arguments.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.