Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete files from target that vanished on source #49

Open
kosli opened this issue Jan 19, 2017 · 10 comments
Open

Delete files from target that vanished on source #49

kosli opened this issue Jan 19, 2017 · 10 comments

Comments

@kosli
Copy link

kosli commented Jan 19, 2017

I thought that when files in the source directory are being deleted, they will be deleted on the target too?
e.g. delete a FLAC file -> it should remove the correpsonding MP3
delete any other file in source, while copyfiles is used, it should be removed in the target dir.

Or perhaps I haven't used flac2mp3 for too long and thought this feature was there. So this is a feature request then ;-)

@kosli kosli changed the title Deleted files from target that vanished on source Delete files from target that vanished on source Jan 19, 2017
@robinbowes
Copy link
Owner

I'd be reluctant to add that sort of feature - I'm not keen on deleting stuff that the tool is not managing.

@kosli
Copy link
Author

kosli commented Jan 20, 2017

@robinbowes how do you mean "stuff that the tool is not managing"? my understanding of the concept of flac2mp3 is that the target directory is in the "possession" of flac2mp3, so flac2mp3 can delete files there without having to worry about them. how do you handle otherwise e.g. when you rename (or move, or delete) a file in the source folder? you delete it manually in the target dir?
i thought the idea of flac2mp3 is to have a "mirrored" target directory, which looks the same as the source, just that the flac files are converted to mp3.

@robinbowes
Copy link
Owner

Yes, that is indeed the operating model. It still makes me nervous deleting things.

@kosli
Copy link
Author

kosli commented Jan 20, 2017

it could just be an additional option to delete data on the target, like it is with the copyfiles?

@carlasplund
Copy link
Contributor

carlasplund commented Jan 20, 2017

Robin's script doesn't handle file renames, it will result in multiple files in the destination directory. And deleted files in the source dir will not have an effect on the destination dir. I have a fork of flac2mp3 where exactly this, and many other issues are addressed. I recommend giving it a try: https://github.com/carlasplund/flac2mp3/tree/develop (i.e. the develop branch).
Two of the added options in my fork are:
--copyfiles Copy non-flac files to dest directories
--delete Delete surplus files and directories in destination, keeping in sync with source dir

@kosli
Copy link
Author

kosli commented Jan 20, 2017

@carlasplund cool, thanks for the info. i looked at some of the forks but didn't find yours with the delete option. maybe @robinbowes wants to take a look at yours commits (especially carlasplund@3d0758d ) and mrege some of them? :-)
will try it out right now. thanks.

@kosli
Copy link
Author

kosli commented Jan 20, 2017

works like a charm. i had to change the --preset option as this is not supported (yet) in your version :-)

@robinbowes
Copy link
Owner

I really need to give this code some love - it's been too long :)

@kosli
Copy link
Author

kosli commented Jul 17, 2017

this one from @carlasplund would be really nice to have it in your master :-)
carlasplund@3d0758d

@trip5
Copy link

trip5 commented Dec 31, 2019

Figured this isn't a bad place to share the init script I made for the Docker container, since most of it is exactly what everyone above is talking about above. Not the cleanest script, since I'm not a coder and basically cobbled it together from various sources but it works. On my Syno 918+, takes about 5 minutes for 9000 files. Works on a very bare Alpine linux distro so it should work everywhere.

if ["$SYNCDELETE" == "1" ] ; then
echo Syncing deletions...
find /in>/tmp/in.txt
sed 's/.flac/.mp3/g; s+/in+/out+g' /tmp/in.txt>/tmp/inx.txt
find /out>/tmp/out.txt
grep -vxF -f /tmp/inx.txt /tmp/out.txt>/tmp/clean.txt
while read line; do rm "$line"; done < /tmp/clean.txt
find /out/. -depth -type d -exec rmdir {} + 2>/dev/null
rm /tmp/*.txt
fi
perl /flac2mp3/flac2mp3.pl $ARGS /in /out
exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants