Results 1 to 5 of 5

Thread: Copy or move file from a .txt source

  1. #1
    Join Date
    Apr 2011
    Beans
    2

    Cool Copy or move file from a .txt source

    Hi there guys!

    Im usign photorec to recover some files that i lost during a format to my hard drive.

    The program works like a charm but put all the files on differents folders. i use the find command to put on a list the jpg files but how i use the cp or the mv command to move that files in the list to another folder?

  2. #2
    Join Date
    Aug 2006
    Location
    Alfandra
    Beans
    355
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: Copy or move file from a .txt source

    Maybe this command line will help. I found it in this thread on linuxquestions.org:
    Code:
    for i in `cat filename`;do mv "$i" destination; done
    Be sure to use "the right thingie": ` not '
    and replace the word destination with wherever you want the files moved to, and filename with the name of the text file

  3. #3
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: Copy or move file from a .txt source

    I did this mulitple times for each file type. The above little command will do the same thing if set up correctly.

    Code:
    #!/bin/baods
    # move files
    
    cd /home/fred/recover
    mkdir ods
    find /home/fred/recover/recup_dir.1 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.2 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.3 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.4 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.5 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.6 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.7 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.8 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.9 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.10 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.11 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/ 
    find /home/fred/recover/recup_dir.12 -name "*.ods" | xargs -i mv {} /home/fred/recover/ods/
    The I found scripts for photos & Flacs to rename them from the internal ids.
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  4. #4
    Join Date
    Apr 2011
    Beans
    2

    Re: Copy or move file from a .txt source

    Quote Originally Posted by dearingj View Post
    Maybe this command line will help. I found it in this thread on linuxquestions.org:
    Code:
    for i in `cat filename`;do mv "$i" destination; done
    Be sure to use "the right thingie": ` not '
    and replace the word destination with wherever you want the files moved to, and filename with the name of the text file
    Thank you very much!

    i use:

    Code:
    find /home/sam/recover2/ -name '*.jpg' -a -size +1M > output.txt
    to create a file name output.txt that contain all the files larger than 1 mb. Then i use

    Code:
    for i in `cat output.txt`;do cp "$i" /home/sam/imagesr/; done
    and i move all the files listed on the output.txt to /home/sam/imaesr

    i hope this can help another person.

    Thank for your support!

  5. #5
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Copy or move file from a .txt source

    you could have skipped the file part
    find allows to perform an action on each found item

    Code:
    find <criteria> -exec mv "{}" <destination> \;

Tags for this Thread

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
  •