Hello guys & girls (are there? )
I tried to figure it out now for 1 hour, but I don't see a easy way.
Is it possible to get all "Level-1" File- & Folder-Names of a folder-path in ONE variable?
(best would be a Conent-list WITHOUT file-suffixes fo my purpose)
I mean, there is a "Get File Name to Variable"-Action AND a "For Each Item in a Collection Execute Actions"-Action... but somehow I see no way, even, if I thnik, it must be easy.
I would be thankful for any suggestions.
for f in ~/"Pictures/Ordner 1"/*; do
printf '%s\n' "$(basename "${f%.*}")"
done
which, of course, can be saved to a variable instead of displayed in a window. The output returned is one filename per line, without filename extensions.
The important syntactical feature to note when copying and pasting the shell code above is the position of the double quotes where I've specified the folder path. ~/ is shorthand for your home directory (i.e. /Users/%you%/), and needs to remain outside the double quotes, with no space; and /* is shorthand for every file and folder at that path, and also needs to remain outside the double quotes, with no space.
The "base name" attribute in the Get File Attribute action returns a file's name without the extension, making this fairly easy to accomplish once you know about it.
Looking to modify so rather than declaring the file path within 'The files in the directory' collection, I use a 'Prompt for File' action to select a folder I want the contents listed out.
I see that I can use a 'Finder's Selection' Collection within the 'For Each' action and I also see that there is a 'Variables Collection' collection.
If I use the 'Prompt for File' action set to 'Prompt for Folder' and have the selected folder create a variable called 'Local__FolderPathForList', can I then use that variable in the next 'For Each' action? If so, how, and please explain.
The For Each Action can be exactly as @gglick's original but instead of a declared path, use the Variable you have obtained through the Prompt for Folder.
Ah, I see the 'The items in directory' option shows up in the 'Folder Contents Collection' and using the format %Variable%(Insert your Variable Here)% is how to place and use a variable that you've set. Thank you!
That basic level of instruction on how to use a variable isn't explicitly explained anywhere, is it, or did I miss it?