Tomulent
Tomulent

Reputation: 571

Script to create a new directory filled with duplicate of specific files

I'm doing some repetitive work that involves creating a directory and duplicating a set of files into it. What i'm looking for is a script that will automate that process for me, which I can put into an Alfred workflow and just call up every time I need it.

I've gotten so far as a script that will create the directory in my front most Finder window, but I want that directory to contain duplicates of 4 specific files.

Upvotes: 0

Views: 75

Answers (1)

Lri
Lri

Reputation: 27633

d="$(osascript -e 'tell app "Finder"
POSIX path of (insertion location as alias)
end')/new folder"
mkdir "$d"
cp /path/to/files/* "$d"
open -R "$d"

Or using AppleScript:

tell application "Finder"
    set d to make new folder at (get insertion location) with properties {name:"new folder"}
    duplicate files of (POSIX file "/path/to/files/" as alias) to d
    reveal d
end tell

Upvotes: 1

Related Questions