1

Disclaimer, this may not be something Automator can do.

I have a large directory of movie files. In order to use a piece of software, each movie needs to be in it's own folder. I'd like to create some sort of automation to do the following:

  • Create folders named after each filename ex: Cool Movie.m4v => 📁 Cool Movie ƒ
  • Move movie file to corresponding folder

I'm hoping that between Automator, Bash, or AppleScript, there's a way to do this.

Clarification:

If I have a folder that looks like this:

  1. Movies ƒ
    • Movie A.m4v
    • Movie B.m4v
    • Movie C.m4v

I'd like it to look like this after:

  1. Movies ƒ
    • Movie A ƒ
      • Movie A.m4v
    • Movie B ƒ
      • Movie B.m4v
    • Movie B ƒ
      • Movie B.m4v
1

In Terminal, change directory to the folder containing the files, e.g.:

cd /path/to/files

Then use the following compound command to do what you've asked:

for f in *.*; do [ -f "$f" ] || continue; mkdir "${f%.*}" && mv "$f" "${f%.*}"; done

If you want to limit it to just .m4v files, then change for f in *.*; to:
for f in *.m4v;

Note that this doesn't make a folder with the ƒ character you've shown, but if it's part of the wanted folder name, then change both occurrences of "${f%.*}" to: "${f%.*} ƒ"

| improve this answer | |
0

I had a similar question and with the help of wch1zpink came up with this solution. In automator:

  1. create a new workflow
  2. add get selected finder items
  3. add run applescript
  4. replace the script with this:

    tell application "Finder"
        set selectedFiles to selection as alias list
        set containingFolder to container of item 1 of selectedFiles as alias
        repeat with i from 1 to count of selectedFiles
            set thisItem to item i of selectedFiles
            set fileName to (text items 1 thru -5) of (name of thisItem as text) as string
            move thisItem to (make new folder at containingFolder ¬
                with properties {name:fileName})
        end repeat
    end tell
    
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .