I'm just starting out using Bash scripts and I'm doing a bit of test code to try and work stuff out.
I'm trying to take the path of a file (that has been dragged and dropped into the terminal) then I want to remove the quotation marks and store it in a variable for later use in a command.
I've got this bit of code that reads the path, stores it in a variable then spits it out with echo (minus the quotation marks):
Code:
#!/bin/bash
clear
echo "Enter source file name & location"
read SourceFile
SourceFile_cut=$SourceFile
echo $SourceFile_cut | tr -d "'"
What I really want to do is store it in a variable and remove the quotation marks, rather than removing the quotation marks as the variable is echoed, I thought this would work, but it doesn't:
Code:
#!/bin/bash
clear
echo "Enter source file name & location"
read SourceFile
SourceFile_cut=$SourceFile | tr -d "'"
echo $SourceFile_cut
I'm doing this test code to try and improve a Bash script I wrote for utilizing the ffmpeg video encoder, it works fine, it's just annoying having to type in the whole path and file name when dragging and dropping a file is much easier:
Code:
#!/bin/bash
clear
echo "Enter source file name & location"
read SourceFile
echo "Enter maximum file size in bytes (SI prefixes allowed)"
read FileSize
echo "Enter destination file name & location"
read DestinationFile
ffmpeg -i $SourceFile -fs $FileSize $DestinationFile