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
  • 2
    Welcome to Ask Different :) Please share what code you have written at your end so far. Also list down any stumbling block that you have hit preventing you from accomplishing the goal. – Nimesh Neema Jan 23 at 15:20
  • Also, please clarify the folder naming convention. Break it down into two lines, one showing the filename and a separate line showing just the folder name, no folder icon. – user3439894 Jan 23 at 15:40
  • I don't have any code written. I don't even know where to start. I've played with Automator to find files and move them to existing locations, but I've never used it to create new files/folders. – John Williams Jan 23 at 15:51
  • 1
    In Terminal, change directory to the folder containing the files, e.g. cd /path/to/files and 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 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 ${f%.*}" to: ${f%.*} ƒ" – user3439894 Jan 23 at 16:27
  • 1
    @Yoric, If you look at the original OP it had ex: Cool Movie.m4v => 📁 Cool Movie ƒ, which has a folder icon and the ƒ and why I asked for clarification however the ƒ may or may not be a meta character denoting a folder. It would have been so much better if the OP has simply said... I have a file named Cool Movie.m4v and I want to create a folder named Cool Movie and move the file into it, while doing the same for each file... etc. No folder icons, no ƒ which may or may not be a meta character denoting a folder, in other words... no ambiguities! – user3439894 Jan 23 at 17:22
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%.*} ƒ"

You must log in to answer this question.

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