I understand Get File Attribute takes a specified file and gets the (in my case) file type/extension out of it, and creates a variable out of that.
My problem is that as far as I can see, for this to work you have to be able to specify precisely which file to get the attribute out of. In my case however, I have a folder (that only ever has one file in it) with a file that keeps changing. So I think I'm trying to work out a way of saying:
"Whatever file is in X folder, get the file type attribute out of that."
I feel like this might be possible somehow but I'm not sure how. I'll be very appreciative if someone can show me.
(be sure to substitute the [PATH TO FOLDER] placeholder with the actual path to the folder, of course)
Alternatively, you could have a macro that gets the file type attribute automatically whenever a file is changed or added to the folder in question with the folder trigger and the %TriggerValue% token:
P.S. When I tried these actions out I kept getting "File" for each file I tested on, regardless of whether it was an image, PDF, text document, or so on, so I'm guessing you might want a different file attribute like "Content Kind" instead, which actually says "Plain Text Document" "PDF Document" etc.
I want to go through a base folder and for each file (and not folder) that ends with an extension out of a list of a few extensions I want to create a subfolder in the base folder with the file's base name and then move the file into that new subfolder.
In the "New Folder" action: where does it get created?
This is currently not working (and – for now – lacks that option to only look for files with certain extensions):
I don't have much time to help today, but the documentation for that action says "The path must be an absolute path (or a path relative to home ~)." In other words, the location is exactly where you specify, and you need to specify the full path (alternatively you could specify a path relative to your home directory.)
So perhaps what you want to do to fix this is extract the full path name for each file. There's an action that will do that for you. I think the action is called Filter. I can't help you today for lack of time.
I'm not sure if I understand the problem. Do you want each file with certain extensions to be placed into a folder and be the only file in that folder? Or do you have multiple files with the same base name and different extensions and you want each of these files to go into the same subfolder?
So very nice of you to care to answer! Much appreciated!
And thanks for the hint with the "New Folder" action, I will look into this.
Indeed, i need to create a folder for each file. It's a crazy prerequisite for a software I use that can only work with folders, not with files directly. And I have a folder full of files where each file now has to go into a folder of the same name minus the extension.
I will experiment further.
Thanks so much again, stay healthy and have a nice weekend!
There's probably a way to do it all with a single KM action, but that wouldn't be the clearest solution, so we'll probably end up with a solution that looks more like your original attempt.
Thanks for asking ... To be honest, I haven't had the time, yet, to look into this any further. I had a quick look if it's easier to accomplish this with Shortcuts or Automator but found that it's not so straight forward there, either (unless, of course, you're fluent in writing a shell script or AppleScript).
I'll come back to you here once I pick it up again.
Sometimes helpful automations don't get finished, because of the time it takes to make them. Sometimes due to the level of skill at that specific moment in time. Still it would be useful to have the automation. That's where this wonderful forum is for right?
Having said that, as a member of this forum let me assist you (hope so).
There are several ways to go about solving your request. Mine if often a ruby or bash script. But then with the slightest wanted change by you, you are depended on these skills (as well). So let me solve your request purely with Keyboard Maestro.
Start as all ways is a clear understanding of the problem. This is what i took as the problem:
"I want to go through a base folder and for each file (and not folder) that ends with an extension out of a list of a few extensions I want to create a subfolder in the base folder with the file's base name and then move the file into that new subfolder."
As I understand this you want this to happen, when this is the start case:
You want this result, when the list of extentions is (txt, pdf, jpg - and not png):
Be sure to change "~/Development/test" in the "For Each Item in a collection.." action into your path
and edit the listOfExtentions (action) as well. All extentions mentioned are included. Each extention is one line, (no preceding period)
Let me know if this works for you, happy to help out.
Cheers
thanks again so much! I learned a lot while studying your solution! It works perfectly! I did get an error in the end (Action failed. File action failed because destination is not a full path file3 in macro "test" (while executing Move or Rename File "%Variable%file%").) – but all the files in my test folder were correctly moved into new folders with those files' base names. That's everything I wanted. I'm so happy! You made my day!
Cheers & thanks again! What a nice forum!!
Stefan.