Results 1 to 5 of 5

Thread: No such file or directory

  1. #1
    Join Date
    Nov 2013
    Beans
    9

    No such file or directory

    Need help on a very simple shell script to convert video from wmv to mp4 format.

    Code:
    #!/bin/bash
    
    for i in *.wmv;
    do
        name=`echo $i | cut -d'.' -f1`;
        avconv -i "$i" -vcodec libx264 -acodec aac -strict experimental  -threads 3 "$name.mp4";
    done

    The folder only contains wmv video but when I run it, I get the error :
    Code:
    *.wmv: No such file or directory
    yet there are dozens of wmv files, that show up when I do
    Code:
    ls -l *.wmv
    but somehow, *.wmv fails to work in the script.
    Last edited by frepie; December 28th, 2017 at 09:30 PM. Reason: spelling

  2. #2
    Join Date
    Nov 2012
    Location
    Halloween Town
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: No such file or directory

    Something like this, perhaps;
    Code:
    #!/bin/bash
    
    FILES=/path/to/files
    
    for f in $FILES
    do
      # take action on each file
    done
    Last edited by slickymaster; December 28th, 2017 at 09:34 PM.

  3. #3
    Join Date
    Nov 2013
    Beans
    9

    Re: No such file or directory

    I appreciate your quick reply but I would like to know why *.wmv is not recognized in the script while it works on the command line.

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: No such file or directory

    Not sure why your script does not work. Are you in the right directory when you run it?


    Linux is very permissive with file names. To prevent any unexpected behaviour, I would try something like:
    Code:
    #!/bin/bash
    
    #with this option *.wmv will also match .WMV .Wmv .wmV ... 
    shopt -s nocaseglob
    
    #don't run the for loop if there are no wmv files in the current working directory
    shopt -s nullglob
    
    for file in ./*.wmv
    do
        name=${file%.*}
        echo "$name" "$file"
    done

  5. #5
    Join Date
    Nov 2013
    Beans
    9

    Re: No such file or directory

    I am puzzled....
    The complete script that failed was as follows (I just didn't copy the commented lines in the first post):
    Code:
    #!/bin/bash
    
    #for %%f in {*.avi} do {
    #avconv -i "%%~nxf" -c:v libx264 "%%~nf.mp4"
    #}
    
    for i in *.wmv;
    do
        name=`echo $i | cut -d'.' -f1`;
        avconv -i "$i" -vcodec libx264 -acodec aac -strict experimental  -threads 3 "$name.mp4";
    done
    Now the script is
    Code:
    #!/bin/bash
    
    for i in *.wmv;
    do
        name=`echo $i | cut -d'.' -f1`;
        avconv -i "$i" -vcodec libx264 -acodec aac -strict experimental  -threads 3 "$name.mp4";
    done
    The only thing I did was delete the comment lines. And now, it works.....

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
  •