COPY with automatic renaming if file with same name already present in folder ???

Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

COPY with automatic renaming if file with same name already present in folder ???

Post by Vilsen »

Every time I empty my camera memory card (and reformat it) it turns out that
SONY does not provide the same incremental file names as with pictures
BUT INSTEAD the same series EVERY TIME ! ? !!! ? ;

This causes a big problem when I copy them into one for film uniform collection
in one and the same folder:

It is not possible to copy a file with SAME NAMES already there!

We know this since ancient times!

Windows has a gallant solution on this problem:

They provide a 3rd option besides the useless = overwrite or skip; Namely: GIVE THE FILE A NEW NAME!

( Even if the question does not arise BEFORE the copying begins
but after a long while , which is idiotic ! )

Thus, for file copying in windows, file duplicates get names like:

MX00001.mp4, MX00001(1).mp4, MX00001(2).mp4 and so on.

I don't want to start WINDOWS ! I really don't want that !

There must be some similar possibility in Linux MINT ??

I usually use Gnome Commander because I am used to it since the time of DOS + win 1, 2,3, 95, 98, XP and so on (1984-2004).

where I can "tell" in advance HOW the copying should behave when it encounter duplicates, but only
with the 2 alternatives: write over, or skip
but NOT with the 3:d option: rename automatically with incremental numbers.

If this could be done in the TERMINAL , I would be as happy as with some file-managing program.

To be clear: I do not want the question: "Do you want to rename this ?" every time a duplicate exists.
And then of course also have to enter the new name with everything it entails in moving
the mouse pointer and everything; It becomes very very much clicking and aiming and moving and clicking then.


This is a large number of films that would be lost unless this worked correctly
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
AZgl1800
Level 20
Level 20
Posts: 11180
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes Sweeping down the Plains
Contact:

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by AZgl1800 »

you have overlooked a very important thing to note.

I always leave the very last file on the SD card, and delete all the previous pictures/videos.

the problem you are asking just does not occur for me anymore.

the camera sees the name of the single file stored, and increments to the next date/time/serial#

this allows me to sort by any means that I wish.... name, or date/time.
and I never loose old files that way.

if you format the card, just copy the last file back to the SD card in the proper place.

My camera is also a Sony, and my cellphone works the same way....
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
User avatar
BenTrabetere
Level 7
Level 7
Posts: 1890
Joined: Sat Jul 19, 2014 12:04 am
Location: Hattiesburg, MS USA

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by BenTrabetere »

AZgl1500's suggestion intrigues me - it is an interesting way to overcome the naming pattern for your Sony camera. I do not own any Sony gear, but I find it odd for a camera not to have a way to allow for sequential numbering.

My solution would be to copy the files to a directory/folder that is dedicated to new images. Next, I would rename those files using the command line or the batch renaming tool in XnView MP. You might also want to take Rapid Photo Downloader for a test drive.

XnView MP is an excellent image viewer that has a nice set of image editing tools. It also has batch utilities for renaming and converting images. It is available as a .DEB from https://www.xnview.com/en/xnviewmp/.

It is also available as an AppImage at https://download.xnview.com/. The file you want is XnView_MP-0.93.glibc2.17-x86_64.AppImage.
Download the file, make it executable, and run.

I do not have much experience with Rapid Photo Downloader - it does not fit in my current workflow. But it does give you a lot of options.
https://www.damonlynch.net/rapid/
Patreon sponsor since August 2022
Image
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by Vilsen »

I am greatful for your suggestion ! I downloaded the program and I will
try if it is possible to use it as you said.

I will be back .

Thanks !
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by Vilsen »

Response to AZgl1500 suggestion:

I did in fact think of something like that . But it takes a lot of time to delete every picture and film.

My camera is a α6300 (ILCE 6300) .

But maybe the second suggestion to format and then restore the last movie might work.

I'll probably try this.

Thanks !!
redlined

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by redlined »

Vilsen wrote: Tue Feb 19, 2019 5:54 am If this could be done in the TERMINAL , I would be as happy as with some file-managing program.
For a quick fix, using tools available in default LM install, via terminal, also see man cp for --backup option, which does what you want automagically, via terminal copy command.
This answer: https://unix.stackexchange.com/a/17293 gives more info, basic command looks like this:
cp -r --backup source target # rename foo → foo~
cp -r --backup=t source target # rename foo → foo.~1~ (or foo.~2~, etc)
man cp shows:
NAME
cp - copy files and directories
SYNOPSIS
cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
DESCRIPTION
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Mandatory arguments to long options are mandatory for short options too.
</>
--backup[=CONTROL]
make a backup of each existing destination file
</>
The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through
the VERSION_CONTROL environment variable. Here are the values:

none, off
never make backups (even if --backup is given)

numbered, t
make numbered backups

existing, nil
numbered if numbered backups exist, simple otherwise

simple, never
always make simple backups

As a special case, cp makes a backup of SOURCE when the force and backup options are given and SOURCE and DEST are the same name for an existing, regular file.
more on cp command- tmi/tl;dr version :mrgreen:

otherwise, Double commander does what you want, takes a bit to configure it but can set as default action to autorename copy/move conflicts, incrementally (possibly even simpler with plugins, it has a good size user base and compatibility with total commander plugins).
it also might be done using Caja (Mate default file manager) or other like Nemo (Cinnamon default) or Thunar (XFCE default, has great bulk file rename ability), or Nautilus (of which at least caja and nemo are forks from, if I recall correctly) using plugins=actions/scripts
here's a decent list of file managers to consider, if such a change is still desired:
https://www.tecmint.com/top-best-lightw ... -managers/

edit to add: link to coreutils/cp online manual...
damonlynch

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by damonlynch »

If you want to use the command line only you must learn how to use ExifTool and / or MediaInfo, depending on which tool does a better job of accurately reading your file's metadata. To automate using them you need to write a script to do so.

Or else you can use Rapid Photo Downloader — which is a GUI tool, not a command line only tool. So that may not suit your needs.

Whatever tool you use you need to adopt a proper naming strategy. From your description you do not appear to have one yet. See for instance https://www.dpbestflow.org/file-management/file-naming
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by Vilsen »

I can really agree that I should learn to write script.
Unfortunately I am old and tired so it can be difficult.

As for naming strategy, it is not me but SONY that is behind this "strategy";
I am happy to adapt to their unwise file name selection.

That's why I ask you how to do it because I've emptied my camera-card
for many years and on a number of different hard drives files
with movies that have the same name.

I can not change the way SONY has decided that my pictures and films will be named !!!!

The only thing I could change was the beginning of the name of pictures:

I changed DSC..... to DSA for the other cameras memorycard so that I can distinguish between them.

I can change the first 3 letters to whatever I want . But not for Movies.

The Sony a6300 cameras creates 4 folders:

MP_ROOT, DCIM, PRIVATE and AVF_INFO


In DCIM resides folders containing the actual picture -files and a VERY STRANGE date-format - see picture -
is present : today is: 11290220 which "SHOULD" mean : 2019 02 20 = 20 feb 2019

Films are still more strangely placed: in 3 different places with different
ideas about how folders should be named, etc.
damonlynch

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by damonlynch »

Vilsen wrote: Wed Feb 20, 2019 7:34 am I am happy to adapt to their unwise file name selection.
Adaption is the wrong choice here. Why be attached to the camera generated file name? It's totally meaningless. Give your files a name that is meaningful to you. If you don't want to write your own script, then try Rapid Photo Downloader, because it does it for you automatically, for both photos and videos, using the naming format you prefer. Simple.
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by Vilsen »

Thank you for your tip!

You probably are right in what you say but you forget one thing:
I have 100,000 OLD pictures and movies that I have to deal with first.

This is WHY I have asked how to achieve renaming.

One more thing: If you are in a hurry - which is often the case - and nothing must go wrong,
you put the memory card in the SD-slot of the computer for this and then you copy everything
that is on the card to a folder with the current date.

Then it is cleard and you can insert the card in the camera and
let the camera format the card so that you know that it works for the next round of pictures and movies.
User avatar
BenTrabetere
Level 7
Level 7
Posts: 1890
Joined: Sat Jul 19, 2014 12:04 am
Location: Hattiesburg, MS USA

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by BenTrabetere »

Vilsen wrote: Thu Feb 21, 2019 7:08 am One more thing: If you are in a hurry - which is often the case - and nothing must go wrong,
I am sensing danger....
you put the memory card in the SD-slot of the computer for this and then you copy everything that is on the card to a folder with the current date.
So far so good. It is at this point where I would rename the files and give them a meaningful, unique filename.

The naming pattern I use starts with a six-digit Date (YYYYMM), a separator (I use underscore), a descriptive name, another separator, and finally a sequence number. e.g., 201902_Afr-Am-Mil-Hist-Museum_006483.CR2

I start with the Date, year first, because it makes it much easier to sort and search. The sequence number I use is the camera sequence number with two zeros added to the front of the number - I figure the camera will be dead or replaced by the time I hit one million.

I rename from the command line, but I have also used the batch renaming tool in XnView. Rapid Photo Downloader is an excellent tool for this work, but I do not use it because it does not fit my workflow.
Then it is cleard and you can insert the card in the camera and let the camera format the card so that you know that it works for the next round of pictures and movies.
Ah, there is the danger. If "nothing must go wrong", I strongly recommend using a different card for the next round of pictures. Memory cards are affordable.

I rotate five SD cards, and I almost never put a card back into rotation until I have processed and archived the images. The only time I recall breaking this practice I almost lost an entire shoot. TestDisk and PhotoRec should be part of your photography toolkit, but you really do not want to have to use them.
Patreon sponsor since August 2022
Image
User avatar
AZgl1800
Level 20
Level 20
Posts: 11180
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes Sweeping down the Plains
Contact:

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by AZgl1800 »

damonlynch wrote: Wed Feb 20, 2019 4:24 pm
Vilsen wrote: Wed Feb 20, 2019 7:34 am I am happy to adapt to their unwise file name selection.
Adaption is the wrong choice here. Why be attached to the camera generated file name? It's totally meaningless. Give your files a name that is meaningful to you. If you don't want to write your own script, then try Rapid Photo Downloader, because it does it for you automatically, for both photos and videos, using the naming format you prefer. Simple.
I too thank you for this great tip.
For a casual hobbiest pix shooter, this is all I need.
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
User avatar
AZgl1800
Level 20
Level 20
Posts: 11180
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes Sweeping down the Plains
Contact:

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by AZgl1800 »

damonlynch wrote: Wed Feb 20, 2019 4:24 pm
Vilsen wrote: Wed Feb 20, 2019 7:34 am I am happy to adapt to their unwise file name selection.
Adaption is the wrong choice here. Why be attached to the camera generated file name? It's totally meaningless. Give your files a name that is meaningful to you. If you don't want to write your own script, then try Rapid Photo Downloader, because it does it for you automatically, for both photos and videos, using the naming format you prefer. Simple.

I too thank you for this great tip.
For a casual hobbiest pix shooter, this is all I need.
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
User avatar
AZgl1800
Level 20
Level 20
Posts: 11180
Joined: Thu Dec 31, 2015 3:20 am
Location: Oklahoma where the wind comes Sweeping down the Plains
Contact:

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by AZgl1800 »

I tried twice to install Rapid * * program.

got this error and it stopped:

Code: Select all

  Downloading https://files.pythonhosted.org/packages/01/8c/eeff014306fcdbb8afda0fe603d1b458dddf2be0ca10d561b0015e439357/PyQt5-5.12-5.12.1_a-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl (61.1MB)
Collecting PyQt5_sip
Received error code 2
Failed to install application requirements: exiting
john@john-TP500LA ~/Downloads/Rapid Photo Downloader $ 

Code: Select all

$ inxi -Fxz
System:    Host: john-TP500LA Kernel: 4.15.0-45-generic x86_64 (64 bit gcc: 5.4.0)
           Desktop: Cinnamon 3.6.7 (Gtk 3.18.9-1ubuntu3.3) Distro: Linux Mint 18.3 Sylvia
Machine:   System: ASUSTeK (portable) product: TP500LA v: 1.0
           Mobo: ASUSTeK model: TP500LA v: 1.0 Bios: American Megatrends v: TP500LA.203 date: 06/11/2014
CPU:       Dual core Intel Core i3-4030U (-HT-MCP-) cache: 3072 KB
           flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx) bmips: 7582
           clock speeds: max: 1800 MHz 1: 828 MHz 2: 1464 MHz 3: 1320 MHz 4: 1479 MHz
Graphics:  Card: Intel Haswell-ULT Integrated Graphics Controller bus-ID: 00:02.0
           Display Server: X.Org 1.18.4 drivers: intel (unloaded: fbdev,vesa) Resolution: 1360x768@59.80hz
           GLX Renderer: Mesa DRI Intel Haswell Mobile GLX Version: 3.0 Mesa 18.0.5 Direct Rendering: Yes
Audio:     Card-1 Intel 8 Series HD Audio Controller driver: snd_hda_intel bus-ID: 00:1b.0
           Card-2 Intel Haswell-ULT HD Audio Controller driver: snd_hda_intel bus-ID: 00:03.0
           Sound: Advanced Linux Sound Architecture v: k4.15.0-45-generic
Network:   Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
           driver: r8169 v: 2.3LK-NAPI port: e000 bus-ID: 02:00.1
           IF: enp2s0f1 state: down mac: <filter>
           Card-2: MEDIATEK MT7630e 802.11bgn Wireless Network Adapter
           driver: mt7630e v: 2.3.8
2.3.8
2.3.8
2.3.8
2.3.8
2.3.8 bus-ID: 03:00.0
           IF: wlp3s0f0 state: up mac: <filter>
Drives:    HDD Total Size: 500.1GB (59.6% used) ID-1: /dev/sda model: Samsung_SSD_860 size: 500.1GB
Partition: ID-1: / size: 28G used: 14G (51%) fs: ext4 dev: /dev/sda1
           ID-2: /home size: 164G used: 116G (75%) fs: ext4 dev: /dev/sda5
RAID:      No RAID devices: /proc/mdstat, md_mod kernel module present
Sensors:   System Temperatures: cpu: 39.0C mobo: N/A
           Fan Speeds (in rpm): cpu: 2600
Info:      Processes: 201 Uptime: 14 min Memory: 979.0/11875.0MB Init: systemd runlevel: 5 Gcc sys: 5.4.0
           Client: Shell (bash 4.3.481) inxi: 2.2.35 
john@john-TP500LA ~/Downloads/Rapid Photo Downloader $ 
LM21.3 Cinnamon ASUS FX705GM | Donate to Mint https://www.patreon.com/linux_mint
Image
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by Vilsen »

HEJ and THANK YOU for all the fine tips and opinions. I would still like to come back to the core of the problem: Namely, I have pictures taken
over a ten-year period and these are available on different hard drives, sometimes the same images are found in several places at hard disk exchanges.

Thus: Perhaps there are up to 100,000 image files and due to stress and uncertainty regarding the life of hard drives (Seagate refuses to answer questions about this), some of these are put in several places.

When Windows (win 7) gives the 3rd possibility: Automatic renaming and I do not want to use windows
it would be nice if this possibility was available in linux MINT.

When it comes to pictures taken today and in the future, one can of course consider smarter routines.

Rotating memory cards are surely smart but if you have like me 3 camera-bodies with different lenses
mounted that are used plus a forthcoming 4th camerabody ; Isn't it a bit "whimsical" then?
User avatar
BenTrabetere
Level 7
Level 7
Posts: 1890
Joined: Sat Jul 19, 2014 12:04 am
Location: Hattiesburg, MS USA

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by BenTrabetere »

Vilsen wrote: Fri Feb 22, 2019 8:13 amRotating memory cards are surely smart but if you have like me 3 camera-bodies with different lenses mounted that are used plus a forthcoming 4th camerabody ; Isn't it a bit "whimsical" then?
Not really. I primarily use 16GB memory cards - they are large enough to hold 600+ images, that size makes the faster cards more affordable, and they are cheap to replace. I have larger capacity cards, but most of the time I use the smaller cards.

I recently bought another backup battery, and cost more than what it would cost to replace my memory card rotation.

I solved the "multiple bodies conundrum" by using permanent markers with different colored inks.
Patreon sponsor since August 2022
Image
Vilsen
Level 5
Level 5
Posts: 984
Joined: Thu Nov 16, 2017 4:45 am

Re: COPY with automatic renaming if file with same name already present in folder ???

Post by Vilsen »

Thanks for all you for your tip but nothing was appropriate to the problem !

You probably are right in what you say but you forget one thing:

I have 100,000 OLD pictures and movies that I have to deal with first.

This is WHY I have asked how to achieve renaming.

t is not possible to copy a file with SAME NAMES already there!

We know this since ancient times!

Windows has a gallant solution on this problem:

They provide a 3rd option besides the useless = overwrite or skip; Namely: GIVE THE FILE A NEW NAME!

( Even if the question does not arise BEFORE the copying begins
but after a long while , which is idiotic ! )

Thus, for file copying in windows, file duplicates get names like:

MX00001.mp4, MX00001(1).mp4, MX00001(2).mp4 and so on.

I don't want to start WINDOWS ! I really don't want that !

There must be some similar possibility in Linux MINT ??
Locked

Return to “MATE”