diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-07-17 07:56:26 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-07-17 07:56:26 -0700 |
commit | 670c43d95b0b5a4ae0f34e1531361d7a0dfcf238 (patch) | |
tree | dd9aac896c3263f596b2744e9bb0319729a77b53 /bin/ifuse-photos-to-tmp | |
parent | 48ee5f986c51f09a17243a103119ec5f63c56525 (diff) | |
download | dotfiles-670c43d95b0b5a4ae0f34e1531361d7a0dfcf238.tar.gz |
automatically import .caf files
Diffstat (limited to 'bin/ifuse-photos-to-tmp')
-rwxr-xr-x | bin/ifuse-photos-to-tmp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bin/ifuse-photos-to-tmp b/bin/ifuse-photos-to-tmp index 5605d294..45b46d24 100755 --- a/bin/ifuse-photos-to-tmp +++ b/bin/ifuse-photos-to-tmp @@ -32,6 +32,7 @@ use File::Spec::Functions; use File::stat qw(stat); use Image::ExifTool qw(ImageInfo); use Syntax::Keyword::Try; +use File::Basename "basename"; # should be absolute paths const my $mount => "$ENV{HOME}/mnt/hermes"; @@ -130,6 +131,28 @@ remove_tree(glob("$mount/PhotoData/Thumbnails/V2/DCIM/10*"), system "fusermount -u $mount"; warn "failed to unmount $mount" unless ($? == 0); +system "ifuse --documents org.videolan.vlc-ios $mount"; +die "could not mount $mount with ifuse" unless ($? == 0); + +foreach my $file (glob qq<"${mount}/Apple CoreAudio format*.caf">) { + my $target = catfile $dest, basename $file; + my $counter = 1; + my $dir = catfile $ENV{HOME}, qw(annex chats), + lc DateTime->now->strftime('%Y/%b'); + my $eventual_dest = catfile $dir, basename $target; + $target =~ s/\.caf\z/-1.caf/ if -e $target or -e $eventual_dest; + $eventual_dest = catfile $dir, basename $target; + while (-e $target or -e $eventual_dest) { + $counter++; + $target =~ s/-[0-9]+\.caf\z/-$counter.caf/; + $eventual_dest = catfile $dir, basename $target; + } + move $file, $target; +} + +system "fusermount -u $mount"; +warn "failed to unmount $mount" unless ($? == 0); + if (fork) { exit; } else { |