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

Rename file if exist #306

Closed
rEnr3n opened this issue Jun 11, 2019 · 8 comments
Closed

Rename file if exist #306

rEnr3n opened this issue Jun 11, 2019 · 8 comments

Comments

@rEnr3n
Copy link

rEnr3n commented Jun 11, 2019

Please add option to rename file if it already exists.

@iamleot
Copy link
Contributor

iamleot commented Jun 11, 2019 via email

@rEnr3n
Copy link
Author

rEnr3n commented Jun 11, 2019

I usually download using gallery-dl -i SOMETEXT

SOMETEXT contains URLs from varying sources. Sometimes it contains URLs like these:

https://example.lan/1.jpg
https://another.lan/1.jpg

@Hrxn
Copy link
Contributor

Hrxn commented Jun 11, 2019

Ah, so you're using gallery-dl like some kind of download manager, like wget?

It's certainly possible, although a bit pointless, maybe. We can't rely on any unique IDs in this case, yes.

Eventually the directlink-extractor could be extended to generate randomized unique-y names here. The archive functionality would be useless in such a case, though.

@github-userx
Copy link

Doesn’t gallery-dl add a _1 to duplicates?

@wankio
Copy link
Contributor

wankio commented Jun 11, 2019

i'm usually using it with this config, so it more like wget

"directlink":
{
"filename": "{path[:120]}+{filename[:80]}.{extension}",
"archive": "~/gallery-dl/archive-directlink.sqlite3"
}

mikf added a commit that referenced this issue Aug 8, 2019
@mikf
Copy link
Owner

mikf commented Aug 8, 2019

extractor.skip now has an enumerate option that adds .1, .2, etc to filenames if they already exist, like Wget does.

@mikf mikf closed this as completed Aug 8, 2019
@Hrxn
Copy link
Contributor

Hrxn commented Aug 8, 2019

Nice, thanks.

Small suggestion: how about adding the numeric suffix between the filename and the file extension, i.e. something like..

standardfilename-1.jpg
standardfilename-2.jpg

instead of

standardfilename.jpg.1
standardfilename.jpg.2

That's what wget does, correct, but in my opinion that wget behaviour is a bit stupid 😄

@mikf
Copy link
Owner

mikf commented Aug 8, 2019

Yeah, you're right. Having files with .jpg.1 as filename extension is probably not very useful on Windows systems.

At first I actually wanted to implement it like you're suggesting by modifying a file's extension, but there were some complications for certain edge cases and I decided to rather go the easier and "already established" way ... I'll see what I can do in that regard.

@mikf mikf reopened this Aug 8, 2019
mikf added a commit that referenced this issue Aug 14, 2019
- change 'has_extension' from a simple flag/bool to a field that
  contains the original filename extension
- rename 'keywords' to 'kwdict' and some other stuff as well
- inline 'adjust_path()'
- put enumeration index before filename extension (#306)
@mikf mikf closed this as completed Aug 17, 2019
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

6 participants