Skip to content

Instantly share code, notes, and snippets.

@dcecile
Created June 27, 2019 16:04
Show Gist options
  • Select an option

  • Save dcecile/9d0943e823daeaeb6371a61fa939cca2 to your computer and use it in GitHub Desktop.

Select an option

Save dcecile/9d0943e823daeaeb6371a61fa939cca2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use File::Copy qw(mv);
use Data::Dumper qw(Dumper);
die if @ARGV < 2;
my $destination = $ARGV[@ARGV - 1];
#my $isRename = ;
if (@ARGV == 2 and not -d $destination) {
my $source = $ARGV[0];
mv $source, $destination;
symlink $destination, $source;
}
else {
my $directory = $destination;
my @files = @ARGV[0 .. @ARGV - 2];
for (@files) {
my $from = $_;
my $to = "$directory$_";
#print "From $from\n";
#print " to $to\n";
mv $from, $to;
symlink $to, $from;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment