Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: filename problem in bash script

  1. #11
    Join Date
    Nov 2012
    Location
    Great Britain
    Beans
    80

    Re: filename problem in bash script

    Quote Originally Posted by steeldriver View Post
    apologies - I omitted the terminator:

    Code:
    find . -ipath "./$file1" -exec cp -n -t "/home/<user>/Audio/language1/" {} \;
    magic! That seems to have sorted the case sensitivity problem, it returned no errors for any of the six and a half thousand files, however it didn't copy any of the files to the new location :S

    find . -ipath "./$file1" -exec cp -n -t "/home/<user>/Audio/language1/audio$count.mp3" {} \;
    find . -ipath "./$file2" -exec cp -n -t "/home/<user>/Audio/language2/audio$count.mp3" {} \;
    find . -ipath "./$file3" -exec cp -n -t "/home/<user>/Audio/language3/audio$count.mp3" {} \;
    find . -ipath "./$file4" -exec cp -n -t "/home/<user>/Audio/language4/audio$count.mp3" {} \;
    find . -ipath "./$file5" -exec cp -n -t "/home/<user>/Audio/language5/audio$count.mp3" {} \;
    find . -ipath "./$file6" -exec cp -n -t "/home/<user>/Audio/language6/audio$count.mp3" {} \;
    echo $count
    count=$(( count + 1 ))
    I also tried it without the -n, still nothing.. what does the -t do? I read that 'exec' causes the script to finish, could that be affecting it as well?

  2. #12
    Join Date
    Apr 2012
    Beans
    5,900

    Re: filename problem in bash script

    Hmm.. that probably just means that the 'find' is failing to find any of the files - that's probably because the pathname isn't an exact match even when case is taken out of the picture - sometimes these things need a bit of tweaking and I'm having to guess what your spreadsheet entries look like (do they have a leading / for example?)

    It would help if you could post one or two specific examples i.e. exactly what the values of "$file1" and the supposedly matching filename are

  3. #13
    Join Date
    Apr 2012
    Beans
    5,900

    Re: filename problem in bash script

    it *should* work, I think e.g. here is a quick test of the basic idea:

    Code:
    $ touch "BiZZarRely nAmeD filE"
    $ 
    $ file="bizzarrely named file"
    $ 
    $ find . -ipath "./$file"
    ./BiZZarRely nAmeD filE
    $ 
    $ mkdir newdir
    $ 
    $ find . -ipath "./$file" -exec cp -vnt newdir/ {} \;
    `./BiZZarRely nAmeD filE' -> `newdir/BiZZarRely nAmeD filE'
    $ 
    $ ls newdir/
    BiZZarRely nAmeD filE
    $

  4. #14
    Join Date
    Nov 2012
    Location
    Great Britain
    Beans
    80

    Re: filename problem in bash script

    well the filepaths are erratic..

    /home/user/NewYork/Update15Nov2011/******** DT/converted/nyect245.mp3

    /home/user/NewYork/********/POR/GL DT POR Nov 28/GL DT POR 008.mp3

    /home/user/NewYork/11Sept2012Update/mp3/English/DT ENG 014B.mp3
    However the software that processes the audio isn't case sensitive, and can run a validity check, which returns all mp3s found, so the csv file lists the correct directory's.

  5. #15
    Join Date
    Nov 2012
    Location
    Great Britain
    Beans
    80

    Re: filename problem in bash script

    for the time being I've solved the problem, by running the script on a Mac, as Macs aren't case sensitive, they are case preserving, the script worked fine with no problems. Marking as solved but open to better solutions for next time...

  6. #16
    Join Date
    Apr 2012
    Beans
    5,900

    Re: filename problem in bash script

    my apologies I completely missed that you were renaming the files (/../../audio$count.mp3) at the same time as copying them - unfortunately 'cp -t' doesn't work in that case (-t specifies a target directory for the copy)

  7. #17
    Join Date
    Nov 2012
    Location
    Great Britain
    Beans
    80

    Re: filename problem in bash script

    Quote Originally Posted by steeldriver View Post
    my apologies I completely missed that you were renaming the files (/../../audio$count.mp3) at the same time as copying them - unfortunately 'cp -t' doesn't work in that case (-t specifies a target directory for the copy)
    No need to apologise
    Thankyou for trying so hard, I really did appreciate your effort!

  8. #18
    Join Date
    Apr 2012
    Beans
    5,900

    Re: filename problem in bash script

    well it's ugly but you might be able to get it to work if you change each cp line to

    Code:
    trufile=$(find . -ipath "./$file1")
    if [ -f "$trufile" ]; then
      cp "$trufile" "/home/<user>/Audio/language1/audio$count.mp3"
    fi
    trufile=$(find . -ipath "./$file2")
    if [ -f "$trufile" ]; then
      cp "$trufile" "/home/<user>/Audio/language2/audio$count.mp3"
    fi
    .
    .
    .

Page 2 of 2 FirstFirst 12

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
  •