From 670c43d95b0b5a4ae0f34e1531361d7a0dfcf238 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 17 Jul 2020 07:56:26 -0700 Subject: automatically import .caf files --- bin/ifuse-photos-to-tmp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'bin/ifuse-photos-to-tmp') 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 { -- cgit v1.2.3