Menu

Commands and Scripts Variables

Anonymous
2014-10-07
2015-03-12
  • Anonymous

    Anonymous - 2014-10-07

    Hello,
    Thanks IgnorantGuru for SpaceFM(GTK2)
    I really like it.

    With a file name like NAME.EXT
    How can I have some variables for only :
    - The File Name Without Extension : NAME
    - The Extension without File name : EXT

    Thanks for your help

    jpalsu

     
  • IgnorantGuru

    IgnorantGuru - 2015-03-12

    SpaceFM doesn't provide these, it's up to you to use bash functions to get them. Maybe there are some functions available for this, or you can see the string operations.

    Roughly you can do

    filename="name.tar.gz"
    ext="${filename#*.}"
    name="${filename%.$ext}"
    echo $name $ext
    : name tar.gz
    

    But this can be a tricky area because some filenames contain periods, etc. Or maybe there's a system level way to do it eg with the 'file' program, not sure.

     

Anonymous
Anonymous

Add attachments
Cancel