Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7810377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:45:24+00:00 2026-06-02T03:45:24+00:00

All, I have shell script which goes through all the media (audio,video) files in

  • 0

All,
I have shell script which goes through all the media (audio,video) files in a user-supplied folder and creates a nice text based metadata report. I’m on a Mac OS X and I’m using Spotlight’s mdls command to get all the relevant metadata. The issue is that sometimes I see “null” results in my report for all the media files. If I run the script again it seems to work. I’m confused why this is happening. This is part of the script that outputs the metadata report:

cd "path_to_folder"
while IFS= read -r -d $'\0' file; do
  duration=`mdls -name kMDItemDurationSeconds "$file" | cut -d "=" -f 2 `
  duration=`printf "%.2f" $duration;`
  pixel_height=`mdls -name kMDItemPixelHeight "$file" | cut -d "=" -f 2`
  pixel_width=`mdls -name kMDItemPixelWidth "$file" | cut -d "=" -f 2`
  codec=`mdls -name kMDItemCodecs "$file" | cut -d "=" -f 2`
  temp="$i) [$file]\n- Duration: $duration\n- Dimensions: $pixel_width X $pixel_height pixels\n- Codec: $codec\n"
  metaDataOutput=$metaDataOutput"\n"$temp
  i=$((i + 1))
done < <(find .  \( -iname \*.m4v -o -iname \*.mov -o -iname \*.mp3 -o -iname \*.m4r -o -iname \*.m4a \)  -print0 )

echo -e  "\n[Report]\n"$metaDataOutput  

The expected output is like this:

1) [./test1.mov]
– Duration: 22.03
– Dimensions: 480 X 640 pixels
– Codec: ( “H.264” )

2) [./test2.mov]
– Duration: 25.03
– Dimensions: 480 X 640 pixels
– Codec: ( “H.264” )

But sometimes the output is null for all the media files:

1) [./test1.mov]
– Duration: null
– Dimensions: null X null pixels
– Codec: ( null )

2) [./test2.mov]
– Duration: null
– Dimensions: null X null pixels
– Codec: ( null )

Am I missing a trick here? Why does the script work sometimes and sometimes outputs null?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:45:26+00:00Added an answer on June 2, 2026 at 3:45 am

    The issue was Spotlight not indexing the files. I used the mdimport command to force Spotlight to index the folder and that has resolved the issue

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a shell script which outputs all of the .js and .html files
I have the shell script which first goes in home directory and backups all
I have a bash shell script that loops through all child directories (but not
Need to have a Shell script that will * Identify all the files [
All, I have a shell script on Mac OS X which uses the mdls
I have a shell script which works perfectly if I run it in the
I have a shell script which I'd like to trigger from a J2EE web
I'm writing a shell script which will rsync files from remote machines, some linux,
I have shell scripting knowledge. I have written a small shell script which will
I have a power-shell script with which I am trying to back up a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.