Moving a Folder based on Folder Content

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Moving a Folder based on Folder Content Sun Dec 05, 2010 9:27 pm • by Sisko2010
What does the following mean. I am not well versed in apple script.

set posix_parent_dir to POSIX path of (container of (item theFile) as text)

I understand that this code is used in order to move Folders ( not files), however
I am not familiar with "(container of (item the File) as text)" what syntax should I be using? Can someone
provide an example? Or do I type in verbatim?

I also got an end tell error when trying to use verbatim.
Sisko2010
 
Posts: 8
Joined: Sat Dec 04, 2010 11:41 am

Re: Moving a Folder based on Folder Content Mon Dec 06, 2010 4:08 pm • by Mr_Noodle
Just enter that into an AppleScript verbatim. Are you entering it directly into the rule or as an external script?
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Moving a Folder based on Folder Content Tue Dec 07, 2010 1:42 am • by Sisko2010
Mr_Noodle wrote:Just enter that into an AppleScript verbatim. Are you entering it directly into the rule or as an external script?


Thanks so much for your reply Mr_Noodle especially to a lowly nubie.

To answer your question the script is being added as embedded as opposed to external.

I had entered the script into Hazel as the following thinking that I had to actually specifiy target and source
folder etc.

tell application "Finder"
set posix_parent_dir to POSIX path of (Users / steven / desktop / HazelTest / (folder C) / (subfolder))
end tell
return {hazelSwitchFile:posix_parent_dir}

Therefore I will type in the following VERBATIM (as below) and see what happens.

tell application "Finder"
   set posix_parent_dir to POSIX path of (container of (item theFile) as text)
   
end tell
return {hazelSwitchFile:posix_parent_dir}

Thanks again for all of your help. Cheers.
Sisko2010
 
Posts: 8
Joined: Sat Dec 04, 2010 11:41 am

Re: Moving a Folder based on Folder Content Tue Dec 07, 2010 1:53 am • by Sisko2010
Sisko2010 wrote:
Mr_Noodle wrote:Just enter that into an AppleScript verbatim. Are you entering it directly into the rule or as an external script?


Thanks so much for your reply Mr_Noodle especially to a lowly nubie.

To answer your question the script is being added as embedded as opposed to external.

I had entered the script into Hazel as the following thinking that I had to actually specifiy target and source
folder etc.

tell application "Finder"
set posix_parent_dir to POSIX path of (Users / steven / desktop / HazelTest / (folder C) / (subfolder))
end tell
return {hazelSwitchFile:posix_parent_dir}

Therefore I will type in the following VERBATIM (as below) and see what happens.

tell application "Finder"
   set posix_parent_dir to POSIX path of (container of (item theFile) as text)
   
end tell
return {hazelSwitchFile:posix_parent_dir}

Thanks again for all of your help. Cheers.


Okay I tried the following verbatim but no move of a folder occurred.

Subfolder Rule
Kind is Folder

Run rules on folder contents

Movies Rule: Change Color and Move
Kind is Movie
Subfolder depth is > 0

Run Applescript (embedded script, exactly as posted)
Set color Label to Yellow

Unfortunately the folder that contains the movies turns yellow (good sign, since it is the last command) but the folder and contents remain in the exact same spot and doesn't move up into the parent directory.

Your help or anyone else readings help would be greatly appreciated.
Sisko2010
 
Posts: 8
Joined: Sat Dec 04, 2010 11:41 am

Re: Moving a Folder based on Folder Content Wed Dec 08, 2010 4:35 pm • by Mr_Noodle
If you want to move the file up a level, just use the move action. In the pop up for destination folder, there is an option to move it up. If you are still having problems, it might help to describe at a higher level what you are trying to do.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Moving a Folder based on Folder Content Thu Dec 09, 2010 1:20 am • by Sisko2010
Mr_Noodle wrote:If you want to move the file up a level, just use the move action. In the pop up for destination folder, there is an option to move it up. If you are still having problems, it might help to describe at a higher level what you are trying to do.

`

Thanks for all your help. It worked as you described. Wonderful program that I am just starting to come to grips with its potential.

Cheers.

S.
Sisko2010
 
Posts: 8
Joined: Sat Dec 04, 2010 11:41 am


Return to Support