Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Help with Directory Structure Naming

  1. #1
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Help with Directory Structure Naming

    I'm trying to copying my photo collection of thousands of photos that are in a folder structure into a single folder so that I can look at managing my collection via tagging rather than having a fixed folder structure. I have looked at several terminal commands and I'm getting to understand(!) what they mean. However, they all fall down with the folder names - I keep getting messages such as No such file or directory - so my naming must be wrong. I keep trying different things like /Home/Pictures/photos, or I cd to Pictures and try photos/ or /photos/ but I'm not getting it right. My latest failure is:

    dad@dadubuntu:~$ find /Home/Pictures/photos -type f -exec cp {} /Home/Pictures/single folder/ \;
    find: ‘/Home/Pictures/photos’: No such file or directory
    dad@dadubuntu:~$


    so in my Pictures folder I have my photo collection in a top level folder called photos. I'm trying to copy all the files into another folder in Pictures called single folder. Any help appreciated as I have too many photo files to copy and paste - this would truely help if I can get this naming convention right.
    Last edited by Quarkrad; November 7th, 2012 at 09:19 AM.

  2. #2
    Join Date
    Jun 2007
    Location
    Malvern, UK
    Beans
    992
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Help with Directory Structure Naming

    it's 'home'. not 'Home'

  3. #3
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Help with Directory Structure Naming

    Still doesn't work.

    dad@dadubuntu:~$ find /home/Pictures/photos -type f -exec cp {} /home Pictures/single folder/ \;
    find: ‘/home/Pictures/photos’: No such file or directory
    dad@dadubuntu:~$ sudo find /home/Pictures/photos -type f -exec cp {} /home Pictures/single folder/ \;
    [sudo] password for dad:
    find: ‘/home/Pictures/photos’: No such file or directory
    dad@dadubuntu:~$


    note. this is a test of only four sub folders and a small number of files within each in Picures/photos. If I can get this to work I will try on my actual collection.

  4. #4
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Help with Directory Structure Naming

    You're missing your username, the full path should be:
    Code:
    /home/dad/Pictures/photos
    or
    Code:
    ~/Pictures/photos
    ~ is a shorthand way of writing your home directory.
    Cheesemill

  5. #5
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Help with Directory Structure Naming

    That did it - many thanks.

  6. #6
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Help with Directory Structure Naming

    For some reason I'm getting outputs with a lock and cross when I use this command:

    sudo find /home/dad/Desktop/old -type f -exec cp {} /home/dad/Desktop/new \;

    or

    sudo find /home/dad/Desktop/old -type f -exec cp {} /home/dad/Desktop/new/ \;

    see attached.

    I can't understand while this is happening. Also, despite my efforts to get rid or rename duplicates before I execute this command some do get through. Is there a way to ammend this command so that if a duplicate file (they are photos) is found it is renamed reather than over written?
    Last edited by Quarkrad; November 18th, 2012 at 09:05 AM.

  7. #7
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Help with Directory Structure Naming

    Its because you're using sudo when you don't have to.

    Because you are using sudo then the file copy operation is being carried out by root, which is changing the ownership of the files accordingly. As you are only working with files in your own home folder there is no need to use sudo at all.

    To change them back you can do:
    Code:
    sudo chown -R dad.dad /home/dad/Desktop/new
    Cheesemill

  8. #8
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Help with Directory Structure Naming

    That did it - many thanks. Can you help on adding an additional element to my 'folder copying' command that will address the issue about duplicate file names? It is poosible for me to have duplicate file names in differenr sub folders that are different photos - so, if possible, I would rather not have duplicates over-written if found - but ideally renamed.

  9. #9
    Join Date
    Apr 2012
    Beans
    7,256

    Re: Help with Directory Structure Naming

    maybe not exactly what you want but a quick and dirty way to handle that might be to use the --backup parameter in cp

    Code:
    $ find . -type f -exec cp -v -t ./ --backup=numbered '{}' \;
    `./dir2/file2' -> `./file2'
    `./dir2/samefile' -> `./samefile'
    `./dir1/file1' -> `./file1'
    `./dir1/samefile' -> `./samefile' (backup: `./samefile.~1~')
    i.e. it renames the 'old' file(s) rather than the 'new' file

    Code:
    $ ls -R
    .:
    dir1  dir2  file1  file2  samefile  samefile.~1~
    
    ./dir1:
    file1  samefile
    
    ./dir2:
    file2  samefile

  10. #10
    Join Date
    Oct 2008
    Location
    UK
    Beans
    1,816
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Help with Directory Structure Naming

    Sorry - I'm a newbie so need a bit of hand holding. Thanks for your help. In old I have 28 sub folders and probably that many again sub sub folders. In all, there are 6573 items - 99%+ of these are actual photos plus a few 'system' files inserted in various places by the Photo Applications like Picasa or Digikam. I can, sort of, work out what your first line is doing if I enter it into the Terminal (assume I cd to the old directory).

    find . -type f -exec cp -v -t ./ --backup=numbered '{}' \;

    But I'm not sure where these lines fit in. I think I have too many directories.

    `./dir2/file2' -> `./file2'
    `./dir2/samefile' -> `./samefile'
    `./dir1/file1' -> `./file1'
    `./dir1/samefile' -> `./samefile' (backup: `./samefile.~1~')

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •