Open porg opened 2 years ago
I think you could accomplish something similar with a xargs -n
or a simple shell script and copyfrom
in it's current form.
Not tested but something like this:
You have a list of file pairs in a file file.txt
:
src1
dest1
src2
dest2
...
Then:
cat files.txt | xargs -n 2 osxmetadata --copyfrom
osxmeta --copypairs <drag n drop files here>
ENTER is just so much more convenient.
But ok if I want drag'n'drop I could write a script only taking $0 (the whole input) which then puts each argument onto its own line, which then counts the numbers of lines:
But yeah, until that works with my skills, again 3-4hours are gone. Shell scripting is always frustrating as soon as whitespace, special characters etc come into play.
And --copylist
I guess can be done when the arguments passed as even-numbered to split them in two multi-line variables and iterate through them osxmeta --copyfrom $src(line $i) $dst(line $i)
. Or split into two files as /tmp/src.txt and /tmp/dst.txt and then merge them line alternatingly (surely a unix tool for this) and then run with your xargs.
But yeah, until that works with my skills, again 3-4hours are gone.
But it's 10-12 hours of my time to implement and test ;-)
cat > files.txt
allows you to copy and drag from Finder then press Ctrl-D when done and use that with xargs
I've been thinking more about this and at least for now I do not intend to work on this. My rationale is this:
--copylist
example) and combined with xargs can do the same as your --copypairs
example. For example, this should work:paste -d"\n" source.txt destination.txt | xargs -n 2 osxmetadata --copyfrom
If there's something that needs to be fixed in osxmetadata to work better with the standard unix command line tools, I'm happy to look at fixing it but I do not want to implement functionality already present in other command line tools unless there's a very good reason to do so.
paste example:
> cat files1.txt
File1-1.txt
File1-2.txt
File1-3.txt
> cat files2.txt
File2-1.txt
File2-2.txt
File2-3.txt
> paste -d"\n" files1.txt files2.txt
File1-1.txt
File2-1.txt
File1-2.txt
File2-2.txt
File1-3.txt
File2-3.txt
One other option, if the source and destination files have the same name you could use osxmetadata to do a backup in the source directory, copy the .osxmetadata.json
file to the destination and then do a restore.
After reading all your arguments I agree that this functionality shall be achieved by interplay of unix tools, and avoid osxmeta to get to big to maintain properly.
But what we very well can do is to add those use cases and solution approaches into the readme.md or the --help or manpage. So I leave this ticket open, and when I found a solution will try to create a nice writeup, which I post here in Markdown Syntax, which you can then embed into readme/manpage/--help as you see fit.
Looks useful! I'll take a look when I get a chance.
Feature Proposal
--copypairs src1 dst1 src2 dst2 src3 dst3 …
--copylist src1 src2 src3 dst1 dst2 dst3 …
Situations of need
Intended use cases as a fruitful collaboration of Finder (GUI) & Terminal (CLI)
--copylist /src/*.png /dst/*.webp