0

I've been using this post as a reference (recursively add file extension to all files) and it has gotten me 90% of the way where I want to be but I'm lost on how to complete the shell script I need.

Here is my script I've made so far:

find /Users/Floyd/Desktop/test -type f -not -name "*.*" -not -ipath "*zworkfolder*" -exec mv '{}' '{}'.mov \;

I want to find all files in the folder "test" that do not have a .mov extension and add the extension to the end of the filename. For the most part it works but I run into a problem when I come up against filenames that have a "." in the filename.
Ex. "A020_C020_0321R7_001_A020_C020_0321R7_001.new.02".

What can I do to make it add a .mov extension to these filenames?

Thank you.

Floyd.

Community
  • 1
  • 1
Floyd
  • 3
  • 2
  • Do you mean "files that don't have a .mov extension", or "files that don't have an extension"? Or something else? `-not -name "*.*"` will eliminate any file with an extension (i.e. which has a dot somewhere in the filename). If you didn't want that, don't put it in the command. – rici Jun 25 '13 at 05:24
  • 1
    Isn't `-not -name "*.mov"` what you need? – Rohan Jun 25 '13 at 05:37

1 Answers1

0

if you don't want files matching *.mov, you should filter by that, rather than the more generic *.*.. thus the following should do the trick:

  find /Users/Floyd/Desktop/test \
       -type f -not -name "*.mov" -not -ipath "*zworkfolder*" \
       -exec mv \{\} \{\}.mov \;
umläute
  • 28,885
  • 9
  • 68
  • 122
  • Thank you! Easy question, easy answer. It works now. Thought I had tried that last night but I was tired so who knows. Thanks again. – Floyd Jun 25 '13 at 14:27