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 ...
- 08-06-2010 #1
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
I noticed that the .jpg are scattered around the 1,000 directories and I want to save time by not doing it per directory.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 $
Thanks in advance!nujinini
Linux User #489667
- 08-06-2010 #2Linux Guru
- 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!
- 08-06-2010 #3
Hello Rubberman!
Haven't given this a try. Not familiar yet.Did you try using the 'find' command to do this?
I was recovering from /dev/sda3 and dumped the results to /dev/sda2 where the recup_dirs are located.BTW, where are the recup_dir... entries 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
Can this apply to my situation?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 \;"
nujinini
Linux User #489667
- 08-06-2010 #4
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
- 08-06-2010 #5the magic is the **Code:
mv **/*.jpg targetFolder
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.
- 08-06-2010 #6nujinini
Linux User #489667
- 08-06-2010 #7
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!
- 08-06-2010 #8Linux Guru
- 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
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!
- 08-06-2010 #9
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:
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.Code:for i in *; do if [ -d $i ] then mv $i/**/*.jpg target; fi; done;
- 08-06-2010 #10Linux Guru
- 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
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!


Reply With Quote
