Recent

Author Topic: In your language: The word Windows uses for a "copy" of a file?  (Read 2351 times)

Aidex

  • Jr. Member
  • **
  • Posts: 82
In your language: The word Windows uses for a "copy" of a file?
« on: October 03, 2019, 03:25:19 pm »
I know this is not a Lazarus specific question, but I need it for my programming, maybe you can help me anyway.

If you copy and paste a file into the same folder under Windows, Windows automatically appends the word "Copy" to the filename, i.e. "File.xml" becomes "File - Copy.xml" or "File - Copy (2).xml".
When my program reads the contents of a folder, I want to ignore such file copies.
My problem is that Windows uses the word of the selected language, e.g. "Kopie" in German, i.e. I have to know the translation used by Windows in each language, so that my program works internationally.

Is there a list of actually used words for "Copy"? Or can you please send me the word used in your Windows' language?!
Is there a similar situation under Linux? What does Linux do if you copy & paste a file to the same folder?

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: In your language: The word Windows uses for a "copy" of a file?
« Reply #1 on: October 03, 2019, 03:40:00 pm »
Different Linux distros may do different things for all I know.
The file browser I use (Nemo) inserts " (copy)" just before the dot of the filename extension.
A second paste inserts " (another copy)" just before the dot of the filename extension.
A third paste inserts " (3rd copy)"  just before the dot of the filename extension.
Note that all new characters are lowercase, and there is also a single leading space character before the opening parenthesis, but no double quote characters which I have added for clarity.

Others would have to say if non-English linuxes use a capital letter, such as in "Kopie".
« Last Edit: October 03, 2019, 03:43:25 pm by howardpc »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: In your language: The word Windows uses for a "copy" of a file?
« Reply #2 on: October 03, 2019, 03:42:42 pm »
There isn't a "Linux" answer to this, since it will depend on the desktop environment any often on the individual program. Dolphin (cut-down Konqueror) and Kate on KDE both ask whether the user wants to overwrite the file rather than automatically generating a new name.

MarkMLl

MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Aidex

  • Jr. Member
  • **
  • Posts: 82
Re: In your language: The word Windows uses for a "copy" of a file?
« Reply #3 on: October 03, 2019, 03:48:58 pm »
Thanks for your answers.
That complicates things even more.
I'm now thinking about whether I'd rather leave this check completely, because the effort for e.g. 100 languages would be very large - and I wouldn't have any guarantee if I hadn't considered any language.
« Last Edit: October 03, 2019, 03:53:25 pm by Aidex »

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: In your language: The word Windows uses for a "copy" of a file?
« Reply #4 on: October 03, 2019, 04:04:42 pm »
Why don't you check file size and whether the file names match in part? If they do then you can calculate the checksum of the file contents. If these match also, both files can be considered to be identical, and you can pick the one with the shorter name.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: In your language: The word Windows uses for a "copy" of a file?
« Reply #5 on: October 03, 2019, 04:09:02 pm »
I think it's worth noting that Lazarus, being oriented towards unix rather than Windows, makes provision for multiple conventions when it comes to making backups of changed source files. In practice, unix programmers have had to consider issues such as file ownership and unexpected changes for far longer than Windows programmers have.

I think that what I'd do would be have one or more patterns (wildmat or regex) that indicate that a file should be ignored (not indexed or whatever), and make sure that the user knows where in the program's configuration the blacklist is stored. So the first time that the program encounters a suspect file it puts up a dialog(ue) asking whether it should always ignore, and telling the user where the persistent setting is stored.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: In your language: The word Windows uses for a "copy" of a file?
« Reply #6 on: October 03, 2019, 04:18:02 pm »
Hi!

You can configure this in the Windows registry.
You need the following line:

Code: Text  [Select][+][-]
  1. [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\NamingTemplates]    "CopyNameTemplate"="[b]%s-[/b]"

If this entry in the egistry does not exist you have to create it.
The % is the filename. The charater behind the s is user defined, in this case a -

Winni

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: In your language: The word Windows uses for a "copy" of a file?
« Reply #7 on: October 14, 2019, 09:49:30 am »
If you copy and paste a file into the same folder under Windows, Windows automatically appends the word "Copy" to the filename, i.e. "File.xml" becomes "File - Copy.xml" or "File - Copy (2).xml".
When my program reads the contents of a folder, I want to ignore such file copies.

I don't think it's a good idea to ignore such files. Sometimes I simply create a copy to have a backup and then change something in the original file. Or the other way round. Now I might want to have both of them in your program.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: In your language: The word Windows uses for a "copy" of a file?
« Reply #8 on: October 14, 2019, 09:57:55 am »
For such issues, at least under Linux, versioning file systems were invented and are available.
Anyway: if you are dealing with your own files, why NOT use a versioning system like svn that can be run locally.
Specialize a type, not a var.

 

TinyPortal © 2005-2018