Finding missing files with a commad or script

The place to post if you need help or advice

Moderators: ChrisThornett, LXF moderators

Finding missing files with a commad or script

Postby GeordieJedi » Sun Jul 20, 2014 10:36 pm

Hi there.

I was wondering if there is an easy and quick way to tell if I am missing a file
in multiple directories and then make a list and output it to a text file.

The situation is I'm running XBMC on my Ras Pi and NAS. Not all of my films (and music) have folder/cover art.
Rather than go through each dir one by one and check. I thought that there must be any easy way to check
this with the terminal command or a bash script.

Something like -
Look at all these dirs (and sub dirs), do they contain the file "folder.jpg"
if not, then name the dir it's missing from and make a list in
a text file for me.

I've taken a quick look on google and I've seen a few that look promising (but they have a bunch of commands
and operators and it quickly begins to look like Klingon).

Any advice or help would be much appreciated.

TIA
User avatar
GeordieJedi
LXF regular
 
Posts: 337
Joined: Thu Jun 14, 2007 10:36 pm
Location: North East England

Postby MartyBartfast » Sun Jul 20, 2014 10:44 pm

Code: Select all
basedir=/media/mymusic

for x in `find $basedir -type d` ; do [ -f "$x/folder.jpg" ] || echo "$x" ; done

I have been touched by his noodly appendage.
User avatar
MartyBartfast
LXF regular
 
Posts: 817
Joined: Mon Aug 22, 2005 7:25 am
Location: Hants, UK

Postby GeordieJedi » Tue Jul 22, 2014 12:34 pm

That worked brilliantly !

Thank you very much MartyBartfast.
You're a star.
User avatar
GeordieJedi
LXF regular
 
Posts: 337
Joined: Thu Jun 14, 2007 10:36 pm
Location: North East England


Return to Help!

Who is online

Users browsing this forum: No registered users and 2 guests