this is just an example what is supposed to happen if you have duplicates.
cp -v is copying in verbose mode and you get to see something along the lines of
in its output.Code:`./dir1/samefile' -> `./samefile' (backup: `./samefile.~1~')
this is just an example what is supposed to happen if you have duplicates.
cp -v is copying in verbose mode and you get to see something along the lines of
in its output.Code:`./dir1/samefile' -> `./samefile' (backup: `./samefile.~1~')
if your question is answered, mark the thread as [SOLVED]. Thx.
To post code or command output, use [code] tags.
Check your bash script here // BashFAQ // BashPitfalls
yes my apologies - those other lines are just the verbose output from cp because I added the -v switch (just to show you the steps it was doing)
For your case, you'd probably want to keep your current command but just add the --backup=numbered parameter
If you have LOTS of files you might want to consider using a form that handles long argument lists a bit more robustly, eitherCode:find /home/dad/Desktop/old -type f -exec cp --backup=numbered {} /home/dad/Desktop/new/ \;
orCode:$ while read -r -d $'\0' file; do cp --backup=numbered "$file" /home/dad/Desktop/new/ ; done < <(find /home/dad/Desktop/old -type f -print0)
Code:find /home/dad/Desktop/old -type f -print0 | xargs -0 cp --backup=numbered -t /home/dad/Desktop/new/
I've done some work and I think I am 'there' but I still need some help -if that's OK. In old I have 6530 items of which 258 are directories. So after running the command I should get 6272 items/photos in new. When I run all three versions of your command I get in new 4726 jpg photos and 1546 files in the form xxxx.jpg~1~ so the command is working - in new I get 6272 items. For example in old I have 4 different photos, with the same file name called DSCF0012.jpg. After I run the command I get in new DSCF0012.jpg, DSCF0012.jpg~1~, DSCF0012~2~, DSCF0012.jpg~3~. In nautilus I can see the image of DSCF0012.jpg but the other 3 ~x~ files are shown with a text type icon (see attached). I guess I need a new command to change these ~x~ into something like DSCF00121, DSCF00122, DSCF00123. I have 1546 of these files - and they are all unique file name wise.
You can probably just bulk rename those using the perl-based 'rename' command so that they have the correct .jpg suffix - something like
The '-vn' switches make it report what it would do but not actually do it - once you have checked that it does the right thing you can remove the 'n' - it should produce something likeCode:$ rename -vn 's/\.jpg\.~([0-9]+)~/-$1.jpg/' *.jpg.*
We can play with the replacement name format if file-N.jpg is not to your likingCode:file.jpg.~1~ renamed as file-1.jpg file.jpg.~2~ renamed as file-2.jpg file.jpg.~3~ renamed as file-3.jpg
try this
n means dry run, if you are sure proposed names are ok, remove that n from the parameter.Code:rename -nv 's/(.+)[.](.+)[.]~(.+)~/$1$3.$2/' *~?~
oops, too late
if your question is answered, mark the thread as [SOLVED]. Thx.
To post code or command output, use [code] tags.
Check your bash script here // BashFAQ // BashPitfalls
Done it - thank you so much for all your help. I believe your solutions will help a lot of people.
Bookmarks