I get into this situation quite often but haven't found a solution. I have a group of CSS files in the clipboard that I need to paste + replace into several different destination folders. My folder structure is similar to
.
├── folderA_11
| └── CSS
| └── file1.css
| └── file2.css
| └── file3.css
├── folderB_11
| └── CSS
| └── file1.css
| └── file2.css
| └── file3.css
├── folderC_11
| └── CSS
| └── file1.css
| └── file2.css
| └── file3.css
├── folderD_22
| └── CSS
| └── file1.css
| └── file2.css
| └── file3.css
├── folderE_33
| └── CSS
| └── file1.css
| └── file2.css
| └── file3.css
└── folderF_44
└── CSS
└── file1.css
└── file2.css
└── file3.css
etc...
There's a pattern: I want to paste to all CSS folders whose container ends in _11 but not any of the others.
The content of the destination folders doesn't matter, I just need to replace them with the new files. Is there a simple way to paste these files into multiple destinations at once? It could also be an Automator flow or Terminal command.
Best Answer
As requested, here's a workable solution as we've discussed in the comments thread. Currently, the situation is that you have multiple files on the clipboard that need to be pasted into multiple destination folders. These destination folders are all called
"CSS"
and reside inside a set of parents folders (names ending"_11"
) that you are able to select en masse.After doing that, you can run the following Automator service, either from the right-click context menu and selecting it under Services (or the Mojave equivalent); or by assigning it a keyboard shortcut in System Preferences, and triggering the service with the press of a hotkey.
The Automator service in question looks like this:
The AppleScript code used in the
Run AppleScript
action is below. The AppleScript reads the list of files contained on the clipboard; isolates the"CSS"
subfolders in each of the selected parent folders that were passed into the service (the"CSS"
folder is created if it doesn't already exist); and then duplicates the files from the clipboard into the"CSS"
directories.If the clipboard does not contain any files, you'll hear a beep and no further action is taken.