-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropscript-tar-czf
More file actions
executable file
·51 lines (46 loc) · 1.17 KB
/
Dropscript-tar-czf
File metadata and controls
executable file
·51 lines (46 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl
#/sw/bin/tar czf "/Users/novak/Desktop/New Archive.tar.gz" "$@"
if (@ARGV == 0) {
# this should never happen since the script should always get
# arguments via drag+drop
die;
}
elsif (@ARGV == 1) {
# Only one argument probably means the user dragged
# a folder. Also possibly a single file.
# Strip everything except the filename
@sheep = split("/", $ARGV[0]);
pop @sheep;
$pattern = join("/", @sheep);
}
else {
# if there's more than one argument, the user is trying
# to make an archive of a bunch of files... Strip common
# parts of the path before making the archive b/c the script
# always gets the full pathname.
$sheep = $ARGV[0];
@sheep = split("/", $sheep);
$n = @sheep;
for ($i=1; $i<=$n; $i++) {
$success = 1;
$pattern = join("/", @sheep);
foreach(@ARGV) {
if (!/^$pattern/) {
$success=0;
}
}
if ($success==1) {
last;
}
else {
pop(@sheep);
}
}
}
foreach (@ARGV) {
s+$pattern/++;
push @args, $_;
}
$args = join("\" \"", @args);
$args = "\"$args\"";
print "/sw/bin/tar czf /Users/novak/Desktop/Archive.tgz --directory \"$pattern\" $args";