Ezfile is a file util more safety than another gem FileUtils
copy_file , mainname, move_file, rename, remainame
gem install ezfile
require 'ezfile'
pwd = Dir.pwd
Ezfile.files("*") # default is "*"
.group_by{|fname| Ezfile.mainname}
.select{|mname, fs| fs.any{|f| Ezfile.extname(f) == ".ass"}}
.each do |fname, fs|
ass = File.combine(pwd, fname +".ass")
mp4 = File.combine(pwd, fname +".mp4")
outf = fname+".done.mp4"
system %Q(ffmpeg -i #{mp4.inspect} -vf subtitles=#{ass.inspect} -c:v h264_nvenc "./out/#{outf}")
endUse Ezfile.help to get help.
Ezfile.help
<<-EOF
require FileUtils and Dir, File.
methods:
MOVE :
::move_file file_path target_dir, mkdir: false
move file to target directory
! if directory is non-exist,
throw an error.
::move_file file_path, target_dir
if non-exist, mkdir
QUERY : its syntax like Explorer Search
::file_list target_dir = "*" alias ::files
::dir_list target_dir = "*" alias ::dirs
show list of files/directories, of target_dir.
! using Dir.glob(target_dir)
::glob query
the same as Dir.glob(query)
RENAME :
::rebasename_file src_file_path, new_basename
it change a file's basename, and ensure never move it or change its parent node.
DELETE :
::ensure_permanently_delete_file target_file alias ::files
::ensure_permanently_delete_directory_and_its_descendant target_dir alias ::files
EOFBug reports and pull requests are welcome on GitHub at https://github.com/saisui/ezfilerb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.