Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby get file folder

path = "/path/to/xyz.mp4"

File.basename(path)         # => "xyz.mp4"
File.extname(path)          # => ".mp4"
File.basename(path, ".mp4") # => "xyz" OR
File.basename(path, ".*")   # => "xyz"
File.dirname(path)          # => "/path/to"

# Alternative to File.extname(path) for multiple extension periods
def full_extname(path)
  ext = File.basename(path).split('.', 2)[1]
  ext.nil? ? '' : ".#{ext}"
end

full_extname('/path/to/xyz.mp4')				# => ".mp4"
full_extname('/path/to/xyz.my.custom.ext.mp4')	# => ".my.custom.ext.mp4"
full_extname('/path/to/xyz')					# => ""
Comment

get directory of current file ruby

__dir__
Comment

PREVIOUS NEXT
Code Example
Ruby :: rails 7 
Ruby :: i am working in ruby 2.6 how to jump to a lower version 
R :: add a vertical line in ggplot 
R :: dplyr replace na 
R :: r - remove scientific notations 
R :: remove null element from list r 
R :: r remove na from dataset 
R :: normalization in r 
R :: glyph in r 
R :: r optim 
R :: negative binomial distribution rstudio 
R :: r change row names of a dataframe 
R :: create a dataframe with column names in r 
R :: r dictionary 
R :: remove rownumbers r 
R :: histogram r add line 
R :: setwd in r 
R :: naming matrix in r 
R :: r as.numeric all columns except 
R :: extract coefficients from lm in r 
R :: r tibble select rows containing string 
R :: r ggplot hide one legend group from multiple legends 
R :: sparklyr alternative for str_detect 
R :: save large nested list to text R 
R :: geom_jitter transparency 
R :: sumif in r 
R :: r - if value in a df is between two number then add 1 
Rust :: convert string to i32 rust 
Rust :: string to bytes rust 
Rust :: use module within another module rust 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =