Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Hello everyone! I am using Mint 7 to do this task and so I decided to post this question here. I used photorec to recover lost/deleted files and after 9 ...
  1. #1
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,230

    Help on Proper Syntax Please

    Hello everyone!

    I am using Mint 7 to do this task and so I decided to post this question here.

    I used photorec to recover lost/deleted files and after 9 hours of process it's finally done

    Anyways, it gave me more than a thousand folders recup_dir files and I just want to get the .jpg and some other files.

    Basically, I need to extract all the jpg files from each 1,000 plus folders and put it in one folder only.

    Folders:
    recup_dir.1
    recup_dir.10
    recup_dir.100
    recup_dir.1000
    recup_dir.1001
    recup_dir.1002
    recup_dir.1003
    recup_dir.1004
    recup_dir.1005
    recup_dir.1006
    recup_dir.1007
    recup_dir.1008
    recup_dir.1009
    recup_dir.101
    recup_dir.1010
    recup_dir.1011
    recup_dir.1012
    recup_dir.1013
    recup_dir.1014
    recup_dir.1015
    recup_dir.1016
    recup_dir.1017

    and so on to folder "pictures" w/c I already made a directory of.

    and so i tried

    Code:
    jun@jun-laptop /media/back-up $ mv *.jpg pictures
    mv: cannot stat `*.jpg': No such file or directory
    jun@jun-laptop /media/back-up $
    I noticed that the .jpg are scattered around the 1,000 directories and I want to save time by not doing it per directory.

    Thanks in advance!
    nujinini
    Linux User #489667

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,977
    Did you try using the 'find' command to do this? BTW, where are the recup_dir... entries located? If they are in / then you can move them into another empty directory on the same device and use "find /dir -type f -name '*.jpg' -exec move {} /home/mydir/photos/recovered \;"
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,230
    Hello Rubberman!

    Did you try using the 'find' command to do this?
    Haven't given this a try. Not familiar yet.


    BTW, where are the recup_dir... entries located?
    I was recovering from /dev/sda3 and dumped the results to /dev/sda2 where the recup_dirs are located.

    Code:
    jun@jun-laptop ~ $ sudo fdisk -l
    
    Disk /dev/sda: 250.0 GB, 250059350016 bytes
    255 heads, 63 sectors/track, 30401 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xc5e3f820
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1        1930    15502693+   7  HPFS/NTFS
    /dev/sda2            1931       15817   111547327+   7  HPFS/NTFS
    /dev/sda3           15818       29555   110350485    7  HPFS/NTFS
    /dev/sda4           29556       30401     6795495   83  Linux
    If they are in / then you can move them into another empty directory on the same device and use "find /dir -type f -name '*.jpg' -exec move {} /home/mydir/photos/recovered \;"
    Can this apply to my situation?
    nujinini
    Linux User #489667

  4. #4
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,230
    Or if I may add... how can I possibly extract all files from all recup folders and group them to folders of the same extensions. Like all jpgs and all txts can be sent to folders jpg and txt respectively so that it can be easier for me to go over it.

    thanks
    nujinini
    Linux User #489667

  5. #5
    Linux Enthusiast Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    718
    Code:
    mv **/*.jpg targetFolder
    the magic is the **

    anyway i would consider to copy the stuff if you have enough disk space. one never knows if mv doesn't replace something because i.e. the filenames are the same.

  6. #6
    Linux Engineer nujinini's Avatar
    Join Date
    Apr 2009
    Posts
    1,230
    Quote Originally Posted by Kloschüssel View Post
    Code:
    mv **/*.jpg targetFolder
    the magic is the **

    anyway i would consider to copy the stuff if you have enough disk space. one never knows if mv doesn't replace something because i.e. the filenames are the same.
    Thanks,

    I tried it but I am not doing it right obviously

    Code:
    jun@jun-laptop ~ $ mv **/media/back-up/pictures/recup_dir*.jpg /media/back-up/jpgs/ 
    mv: cannot stat `**/media/back-up/pictures/recup_dir*.jpg': No such file or directory
    jun@jun-laptop ~ $
    nujinini
    Linux User #489667

  7. #7
    Linux Enthusiast Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    718
    Remind: ** expands to all files and folders recursively, just like * does expand for all files and folders within a directory but without recursion.

    are you serious? if so, stand up and take a walk. you need a break!

  8. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,977
    Quote Originally Posted by Kloschüssel View Post
    Remind: ** expands to all files and folders recursively, just like * does expand for all files and folders within a directory but without recursion.

    are you serious? if so, stand up and take a walk. you need a break!
    Standard mv syntax (man page or --help) make no mention of this '**' option, at least on CentOS/RHEL. What system are you running? Also, if it does expand to all the available matches, beware of exceeding a single command line length. Since he likely has a lot of candidate files, this would be a definite problem I would think.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  9. #9
    Linux Enthusiast Kloschüssel's Avatar
    Join Date
    Oct 2005
    Location
    Italy
    Posts
    718
    of course is ** not written down in the mv man pages as it is not a mv command / switch / operation / whatever. it is just like * a shell operator that matches everything and will be expanded by the shell to a set of command arguments. you are obviously right. if he has tons of files that will be passed on to the mv command as arguments, his shell will tell him: "uoh, not with me good boy!" but that's another story. in most cases this will work. if it doesnt he can still try:

    Code:
    for i in *; do if [ -d $i ] then mv $i/**/*.jpg target; fi; done;
    if all doesn't help, he will need to write a script that recursively iterates over the folders and moves all images to a target one by one.

  10. #10
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,977
    Quote Originally Posted by Kloschüssel View Post
    of course is ** not written down in the mv man pages as it is not a mv command / switch / operation / whatever. it is just like * a shell operator that matches everything and will be expanded by the shell to a set of command arguments. you are obviously right. if he has tons of files that will be passed on to the mv command as arguments, his shell will tell him: "uoh, not with me good boy!" but that's another story. in most cases this will work. if it doesnt he can still try:

    Code:
    for i in *; do if [ -d $i ] then mv $i/**/*.jpg target; fi; done;
    if all doesn't help, he will need to write a script that recursively iterates over the folders and moves all images to a target one by one.
    Of course it's a shell exapnsion! Doh! (insert head slap here). Brain fart - teaching class last night until 10pm and didn't get to bed until late...

    Still, expansion can still cause a command-line overflow in the shell. But that's another issue (though perhaps relevant here).
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Page 1 of 2 1 2 LastLast

Posting Permissions

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