Find the answer to your Linux question:
Results 1 to 2 of 2
I am a complete novice. The following cut command works perfectly to trim a filename and output to the text file the new, correct filename. What I cannot figure out ...
  1. #1
    Just Joined!
    Join Date
    Feb 2012
    Posts
    1

    bash file rename half solved

    I am a complete novice.

    The following cut command works perfectly to trim a filename and output to the text file the new, correct filename.

    What I cannot figure out is how to MV the filename from the OLD name to the NEW name which is the output of the CUT command?

    Suggestions?

    ls -1 *pdf* | cut -f4 -d_ >list.txt

    Thanks,

    Rob

  2. #2
    Just Joined!
    Join Date
    Jan 2011
    Location
    Fairfax, Virginia, USA
    Posts
    94
    Hi Rcr,
    Is something like this what your interested in?
    Code:
    for original in *.pdf
    do
        newName=$( echo $original | cut -f4 -d_ )
        mv $original $newName
    done

Posting Permissions

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