AUTOMATOR : new folder copy in another directory

Hi


I'm still learning Automar and Applescript.


I'm trying to create an Automator folder action when a new folder is created in my directory.

Specifically I would like when a new folder is created in said directory :

  • to create a new (empty) folder with the same name in another specific directory
  • and a must would be to add the same tags as the original folder too but I think it's a little too complicated for me


I did this Applescript to create a new folder with the same name within the original one and then I transfer it manually in the other directory.


on run {input, parameters}


repeat with new_folder in input


tell application "Finder"

set f_name to name of new_folder

make new folder at new_folder with properties {name:f_name}

end tell

end repeat

end run


I can't find a way to transfer the new folder automatically. Futhermore it would be more efficient to create it directly in the other directory but I'm not that proficient yet.


Could someone help me ?

Thanks

Posted on Jul 18, 2022 12:48 AM

Reply

Similar questions

5 replies

Jul 18, 2022 11:28 AM in response to Tanpopo33

> it would be more efficient to create it directly in the other directory but I'm not that proficient yet.


that's pretty straightforward, assuming the destination is consistent.


Consider your code:


			make new folder at new_folder with properties {name:f_name}


the at parameter tells the Finder where to create the folder. Just change this to the path where you want it to go, e.g. to define a subdirectory in your Documents folder:


			make new folder at folder "blah" of (path to documents folder) with properties {name:f_name}


or maybe on your desktop:


			make new folder at folder foo of (path to desktop) with properties {name:f_name}


or maybe some arbitrary location:


			make new folder at folder "Macintosh HD:Users:username:some:funky:directory:" with properties {name:f_name}


(note the first two examples should be written exactly as posted - the 'path to' command will find the current user's Documents or Desktop folder without you having to do any extra work).


As for the tags:


> and a must would be to add the same tags as the original folder too but I think it's a little too complicated for me


Do you mean the newly created folder? that wouldn't have any tags associated with it, since it's just been created. Or maybe I'm missing something?

Jul 18, 2022 4:28 PM in response to Tanpopo33

> or perhaps it's impossible for dropbox path but I did try other pathes and still nothing.


Dropbox does add a layer of complication. Can you try it with a static directory on your system to see if that makes a difference. For example:


		make new folder at (path to Desktop) with properties {name:f_name}


this should make a new folder on your desktop. From there we can refine it.

Jul 18, 2022 11:58 AM in response to Camelot

Hi,

Thanks for your answer. I did try the folder path like that but it did'nt work so I assumed I did something wrong. I just tried again with different folder path and still not working. I don't know perhaps another script is conflicting with it.


I have this one runnning too


on run {input, parameters}


repeat with new_folder in input


tell application "Finder"

set f_name to name of new_folder

make new file at new_folder with properties {name:f_name}

end tell

end repeat

end run


And with the previous scrip creating a new folder in the original one, the 2 couldn't work together. Only one can work at a time. I thought if the new folder was created directly in another directory (which is what I wanted) it would not conlift but it seems so... I tried to combine them in one script and workflow and not 2 but to no avail. I

'm actually learning everything by tweaking and failing ^^


For the tags, I immediately set tag to the parent Folder, so I'm not sure if it's possible for the empty folder to get them too.

Jul 18, 2022 12:17 PM in response to Tanpopo33

I did try this other one :


on run {input, parameters}


repeat with new_folder in input


tell application "Finder"

set f_name to name of new_folder

make new file at new_folder with properties {name:f_name}

make new folder at folder "Macintosh HD:Users:elleam:Dropbox:@WEBTOONS" with properties {name:f_name}

end tell

end repeat

end run



or perhaps it's impossible for dropbox path but I did try other pathes and still nothing.


I did try without making this other action :


make new file at new_folder with properties {name:f_name}


but it's still not working.

Jul 19, 2022 8:39 AM in response to Camelot

Hello,


Thank you for your help, the beginning of my path was wrong. Such a stupid mistake, that's why it did'nt work whichever the final path I tried. And it's working in dropbox too so it's great !

For the tags it would be helpful but it's not a necessity. I'm still trying to make other scripts work.


I'm sorry for asking this of you, you already helped me so much and in previous posts too, but if you have the time could you please give me some advices on this one ? Or just if it's something remotely doable with my poor skills.


I kwow it's really more complicated and I'm not sure I explained it well.


Automator : compress selected files by X … - Apple Community


Thanks again


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

AUTOMATOR : new folder copy in another directory

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.